Basic addition & subtraction throws up a whacky number?

peskywinnets

Registered User.
Local time
Today, 20:42
Joined
Feb 4, 2014
Messages
582
So I have a problem where an e table is throwing up some whacky numbers

In my access table I have configured as "doubles"

The ShippingTotal field is calculated by a basic formula .... ShippingNet + ShippingTax - ShippingDiscountNet - ShippingTaxDiscount

in the access table it all looks correct *until* I click into the ShippingTotal field...

ShippingNetShippingTaxShippingDiscountNetShippingTaxDiscountShippingTotal
1.870.371.870.370
3.740.75004.49


where I get this...

ShippingNetShippingTaxShippingDiscountNetShippingTaxDiscountShippingTotal
1.870.371.870.371.11022E-16
3.740.75004.49

...Any ideas? (it seems to be when there are values in all fields and where the end result should be calculated as zero ....possibly Access is throwing in some rogue decimals somewhere?)
 
Last edited:
Hi. Must be a typo, or I'm going blind, because both numbers look the same to me.
 
Edit: I thought I'd sorted this but spoke to soon ...the problem is still there
 
When you click in a field, you get the actual calculated value. In this case its indicating a value slightly above zero with a value of 1 in the 16th decimal place. Click outside and you see the displayed value i.e. zero after rounding

The reason why the calculated value is not exactly zero is because doubles are floating point numbers and that an lead to unexpected outcomes. See e.g. https://www.consultdmw.com/floating-point-numbers.html
 
Thanks...I fixed it by using the decimal data type for the table fields .....my calculations now end up as result of 0 vs. the whacky number!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom