Rounding Up

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

The function Cint() rounds .5 up/down to the nearest even
number. I need a function that rounds up for all
numbers..ie 2.5 to 3 (not 2), 3.5 to 4.
Any ideas?
 
Eric said:
The function Cint() rounds .5 up/down to the nearest even
number. I need a function that rounds up for all
numbers..ie 2.5 to 3 (not 2), 3.5 to 4.
Any ideas?

CInt(YourNumber + 0.5)

David
 
Thanks for your response.Unfortunately 3.0 would go to
4.0 if I added .5
My thought is if my number is even I can add .1 if odd
its OK.
Hence I came up with:
IIf(Int([MyNumber]/2)*2-Int([MyNumber])=0,Cint([MyNumber]
+.1),Cint([MyNumber]))

I was wondering if there was anything simpler.
 
Use a tiny MarginOfError, says, 0.000001 in CInt.

For example (from Debug window):

MarginOfError = 0.000001
?CInt(2.5 + MarginOfError)
3
?CInt(3.5 + MarginOfError)
4
 
Back
Top