Results 1 to 4 of 4

Thread: Restrict double precision

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Belgium
    Posts
    77

    Restrict double precision

    Hi,

    I do a operation that return a number like x.xxxxx... and I only want to keep x.xx (2 number of precisio nafter the commat). I suppose there is a simple function like in C# to do that ?

    Thanks for help

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    VB Code:
    1. Dim x As Double
    2.         x = 5.685698458945
    3.         x = System.Math.Round(x, 2)
    4.         MsgBox(x)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Belgium
    Posts
    77
    Thanks you

  4. #4
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    exactly right but just be aware that the round method uses bankers rounding and always rounds to an even last digit, which can casuse edless problems when users check your maths and tell you it does not agree with their own calculations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width