Rounding Question

G

Guest

Does anyone know if the format function ("Format/Number with x number of
decimal places) happens to conform with ASTM E29 for the last right-hand
digit...???


Thanks

Paul
 
R

Ron Rosenfeld

Does anyone know if the format function ("Format/Number with x number of
decimal places) happens to conform with ASTM E29 for the last right-hand
digit...???


Thanks

Paul

Format function? Are you talking about the VBA Format function?

If so, it does not, as I understand you. The Format function returns a string
of digits rounded according to the format expression. The rounding is done in
the same method as the Format Cells dialog in Excel.

Of course, the Format function actually changes the value. Whereas the Format
Cells dialog only changes how the value is displayed.

The VBA Round Function in VBA6+ does conform to the standard, as far as I know.
It rounds the midway numbers to the nearest even number.


--ron
 
B

Bernard Liengme

Hi Paul,
A simple experiment will show you that 1.575 rounds to 1.58 while 1.585
round to 1.59 with formatting and with the ROUND function. Clearly Excel
does not use the ASTM E29 protocol (aka Banker's Rounding)

However, VBA does follow ASTM E29
(see http://support.microsoft.com/default.aspx?scid=kb;EN-GB;q194983 and
http://support.microsoft.com/default.aspx?scid=kb;EN-US;196652)
So the user-defined function below will round both 1.575 and 1.585 to 1.58
Function myround(rng, fig) myround = Round(rng, fig)End Functionbest wishes
 
G

Guest

VBA's Round function does not handle the vaguaries of binary approximations
very well, for instance myround(1110*0.0865,2) will round down instead of up.
Your code will often produce more satisfactory results if you use
Round(CDbl(CStr(rng)), fig)

Also, VBA's Round function does not support negative arguments in the way
that the worksheet function does. The code I posted at
http://groups.google.com/group/microsoft.public.excel.charting/msg/107fce6145b70d69
deals with this shortcoming.

Does anyone know of any instances where bankers have EVER rounded in this
way? Barring that, does anyone know how this came to be called "Banker's
Rounding"?

Jerry
 

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