View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Jerry W. Lewis Jerry W. Lewis is offline
external usenet poster
 
Posts: 837
Default Round doesnt work the way it is expected

The VBA Round() function uses what MS calls "Banker's rounding"
http://support.microsoft.com/kb/194983
which rounds to the nearest rounded number, but handles ties differently
than you were expecting. You expected ties to always round up, which can
introduce a rounding bias. The so called "Banker's rounding" tries to
roughly balance the number of times that ties round up or down by rounding
ties so that the final rounded digit is even. This has been the ASTM
standard for rounding since the early 1940's and has been best practice for
nearly a century.

Nick is partly right, in that the IEEE 754 standard specifies that rounding
of internal binary numbers be to an even final digit. IEEE 854 extends this
to natively decimal calculations, but I don't think that it applies to how
you round the decimal representation of natively binary calculations. About
10 years ago, an informal survey of computer languages found them about
evenly divided as to which rounding method they implemented.

Why MS calls it "Banker's rounding" is a mystery to me, since as far as I
can determine, bankers have never used it. I would welcome an explanation of
the history of this name, evidence that bankers have ever used it, or
pre-1940 references to this type of rounding.

Jerry

"Carlo" wrote:

Hello all

i'm a little confused here. Hope somebody can help me.
With following code:
---------------------------------------------------------
Sub Whyyyyyyyyyyyyyyyyyy()
x = 1.5
For i = 1 To 4
Debug.Print "(" & x & " * " & i & ") = " & x * i & " == Round(" & x
* i & ") = " & Round(x * i, 0)
Next i
End Sub
---------------------------------------------------------
VBA returns me:
------------------------
(1.5 * 1) = 1.5 == Round(1.5) = 2
(1.5 * 2) = 3 == Round(3) = 3
(1.5 * 3) = 4.5 == Round(4.5) = 4
(1.5 * 4) = 6 == Round(6) = 6
------------------------

Why is Round(1.5) = 2 and Round(4.5) = 4 ?????

I don't really get it!


Thanks for any help

Carlo