Rounding a number to the nearest 0.005 ????????

  • Thread starter Thread starter Benn Vosloo
  • Start date Start date
B

Benn Vosloo

I would like to round a number to the nearest 0.005 i.e
0.0124 becomes 0.0100 or 0.0826 becomes 0.0850 of 0.0761
becomes 0.0750 or 0.0779 becomes 0.080. Is this possible?
Can anybody help please?

Thanx
 
Benn Vosloo said:
I would like to round a number to the nearest 0.005 i.e
0.0124 becomes 0.0100 or 0.0826 becomes 0.0850 of 0.0761
becomes 0.0750 or 0.0779 becomes 0.080. Is this possible?
Can anybody help please?

Your calculations are off for 3 decimal places. The Round function is built
into later versions of Access:

?Round(0.0124,3)
0.012

?Round(0.0779,3)
0.078

If you are using version 97 or earlier try this:

http://www.mvps.org/access/modules/mdl0054.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Hi,


with VBA6: (Access 2000 or later)


RoundedNumber = Quantum * Int(0.5+ NumberToBeRounded / CDec( Quantum) )

where Quantum, in your case, is 0.005.

Using a Decimal, CDec, reduces the possibility of false rounding that may
occur when a number is not really what it seems it is. As example, 0.2 can
be, in fact, precisely either 0.20000000006, either 0.19999999994, as
example, we can't really know unless we really look at the exact bit
representation. CDec(0.2), on the other hand, would always be 0.2, exactly.



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top