Results 1 to 4 of 4

Thread: Rounding in Win98/2K vs. XP and Vista

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    18

    Rounding in Win98/2K vs. XP and Vista

    I have a function that would round off to currency format:

    CCur(Format(Text1.Text, "###,###,###,###.00"))

    Now Windows XP and Vista will always round up, so 0.225 will return 0.23, and 0.235 will be 0.24.

    However windows 98 and 2000, will round depending on whether the second last digit is odd or even, if its odd it rounds up, and if even it rounds down. So 0.225 will be 0.22 and 0.235 will be 0.24.

    Any idea why this is happening, or better yet any thing from MS to get a consistency going. I really couldn't find any docs about this anywhere and just found it through trial and error after some discrepancies our customers have been coming across.

    Thanks,
    Luke

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Rounding in Win98/2K vs. XP and Vista

    I believe that issue only applies to the Format functions, and rightly so because the returned strings should be used for display purposes only, and not for further calculations. The Round function and type conversion functions use the 'round to even' method you described.

    That said, formatting a string before converting it to any numeric data type is quite pointless, as the format is not maintained. The currency data type has 4 digits to the right of the decimal point, and it may be best to keep this higher accuracy. When you do need to round the values, you should use the Round function.

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Rounding in Win98/2K vs. XP and Vista

    I'm not entirely sure you've stated the situation correctly, but there was a bug in XP Gold that was fixed in SP1.

    I find that XP SP1, XP SP2, XP SP3, Vista Gold, and Vista SP1 all work like Win2K. None of them quite match your results.

    The Format() Function Gives Different Results in Windows XP Than in Windows 2000

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Rounding in Win98/2K vs. XP and Vista

    Working in the financial industry we never trust the OS to do the rounding we ALWAYS do it programically. We would basically add .005 to the number then truncate the results. This procedure will always work as expected no matter what system it is done on...

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