Link to home
Start Free TrialLog in
Avatar of dsoderstrom
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?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dsoderstrom
dsoderstrom

ASKER

Thanks for the help and the quick reply
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