dsoderstrom
asked on
How to return unrounded number
In MS Access vba code I want to return an unrounded version of a number trunctated to a specified number of decimal places.
For example, I have a number of 131.2999999998
I want to truncate this number to 3 decimal places and end up with 131.299, NOT 131.3
How do I do that?
For example, I have a number of 131.2999999998
I want to truncate this number to 3 decimal places and end up with 131.299, NOT 131.3
How do I do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just in case anyone should happen to look up this post:
That is really the most clumsy rounding "method", I've ever seen. And it fails in an international environment.
Numbers should always be handled like numbers.
Here is how to do this:
dblNumber = 131.2999999998
lngNumber = Int(dblNumber * 1000) / 1000
Returns 131.299
/gustav
That is really the most clumsy rounding "method", I've ever seen. And it fails in an international environment.
Numbers should always be handled like numbers.
Here is how to do this:
dblNumber = 131.2999999998
lngNumber = Int(dblNumber * 1000) / 1000
Returns 131.299
/gustav
ASKER