Forum Discussion
Rounding decimals in a math operation
Hi,
You can e.g. use the Format function like this: Format(Whatever, "#")
There are also many user defined Rounding functions like the one on my website (in German, but the code works for other languages too ;-).
Servus
Karl
*********
http://AccessDevCon.com
https://www.donkarl.com
- isladogsJul 13, 2021MVP
As Karl suggested there are many ways of doing this, jncludjng formatting.
Other methods using built in functions include
?CInt(2.56) 3 ?Round(2.56,0) 3 ?Int(2.56)+1 2 ?Fix(2.56)+1 3
Int and Fix both give the integer value so you need to add 1 to the result
But what if the result is nearer to the lower integer value e.g. 2
Both CInt and Round will now round down so you would need to add 1.
So avoid those as not consistent.
Now consider negative results such as -2.56 or -2.16
Assuming you want the result to be -2 in each case, then the only function that always gives the desired answer in all scenarios is using Int(number)+1
Hope that makes sense