Rounding Error

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?
 
R

Ron Rosenfeld

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
 
A

Arvi Laanemets

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top