Rounding in text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I use the Round fuction in a text box that the number ends up being 20.685 it comes up with 20.68 when it should come up with 20.69. Does anyone know how to fix this?
 
Format(20.685,"#,##0.00")

With a text box control you could also just set the Format
property to 'Standard', and DecimalPlaces property to 2.

-----Original Message-----
When I use the Round fuction in a text box that the
number ends up being 20.685 it comes up with 20.68 when it
should come up with 20.69. Does anyone know how to fix
this?
 
-----Original Message-----
Format(20.685,"#,##0.00")

With a text box control you could also just set the Format
property to 'Standard', and DecimalPlaces property to 2.

Elwin,

While it seems Format will solve the problem, do you have
any idea why Round doesn't round per the standard
convention?

Kevin Sprinkel
 
Round() is just an old function. It does work half the
time though.

Round(20.685,2) returns 20.68
Round(20.675,2) also returns 20.68

Round(20.6855,3) returns 20.686
Round(20.6865,3) returns 20.686


When the value of the decimal place indicated by the 2nd
parameter is even the function rounds down, when its odd
it rounds up. I guess the first generation of developers
wanted to add spice to their applications. I prefer not
so much. :)
 
Access uses what is called Bankers Rounding, which has this behavoir by
design. Keeps the accounting types happy, since on the average it doesnt
produce accumulated drift due to multiple roundings.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top