Rounding Error

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Worksheet function =Round(0.965,2) returns 0.97
Using VBA Round(0.965,2) returns 0.96.
Why does the VBA function not work properly?
 
Worksheet function =Round(0.965,2) returns 0.97
Using VBA Round(0.965,2) returns 0.96.
Why does the VBA function not work properly?

VBA's round does work properly. It just uses a different rounding method,
sometimes called banker's rounding. This is outlined in the MSKB article
225330.

Briefly, if the number to the right of your rounding point is '5', and the
number to the left is even, then the number will get rounded down.

So (0.965,2) --> 0.96
(0.955,2) --> 0.96


--ron
 
Hi

I'm not sure (I haven't used rounding in excel VBA ever), but it looks
pretty like so-called banker's rounding for VBA (a tie is rounded up or down
depending the value is even ur uneven). PS. Banker's rounding is used in MS
Access.


Arvi Laanemets
 
Back
Top