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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiplication Error in Access VBA 1

Status
Not open for further replies.

swaybright

Technical User
Jun 25, 2003
156
US
Hi All,

I have a rather frustrating problem... I hope someone can provide some insight.
I have a complex equation that of which one part is simple multiplication: 15.8 * 5.1

This should equal 80.58 Right?
But Access VBA returns the value: 80.5799984931946

While I know this will round to the correct value, it is important that Access returns the real value.
This is only one example of this recurring problem which becomes critical when it occurs within an equation that should reduce to zero.

Does anyone know why this happens. And how do I correct it?
Thanks for any suggestions!

Shane
 
The result of the equation is dimmed single. . .
However this result is pulled from the parenthesis within the equation when I step through the code i.e.

Value = ((A - B) * ((G * L) - (H * K)))- . . . .(six more terms)
G = 15.8
L = 5.1
 
NO digital/binary system calculates like ye-olde-pencil&Paper. Certain values are just NOT able to be represented. There are pratical soloutions, depending on your specific implementation. One is to promote (multiply) the values so they are whole numbers, do the multiplication, and divide them back to the appropiate number of decimal places. Another is to use the ROUND function to set the number of decimal places. There are others.





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Thanks guys. I think the Round function is the way to go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top