Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need assistance in truncating repeating decimal 1

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
Hello, I am doing a division math problem in Access 2000 VBA like so:

[120Ratio] = ([120Actual] / [120Spec])

Most of the time this result ends up in with many decimal places or in a repeating decimal. Some times it actually ends up with just 1 or 2 decimal places. I would like to truncate the large decimal place numbers to 4 decimal places but don't know how this will affect the numbers with only 1 or 2 decimal places. Thank you for any advice.
 
If you want to truncate (as opposed to round) then
Code:
[120Ratio] = Int(([120Actual] / [120Spec]) * 10000) / 10000.0
 
[120Ratio] = Int(([120Actual] / [120Spec]) * 10000) / 10000.0

This won't let me enter the 10000.0 it always turns it into 10000# Does this make sense ?
 
It does.

"#" is the type character that designates a floating point value. It regards ".0" as forcing the value to be floating point (which was the intent) so it just replaces ".0" with "#" to designate the value as floating point.

Is that more or less confusing?
 
Thank you so very much Golom. Your help is greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top