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

Summation Problem

Status
Not open for further replies.

bls123

Programmer
Nov 6, 2005
2
MY
I have a serious problem with summation using a query. I hope somebody can help me urgently.

I have a list of numbers stored in a double precision field using Microsoft Access 2000. The list is as follow.
-5.36,-7.36,-0.8,-1.13,5.36,7.36,0.8,1.13

When I execute the query : "SELECT sum(fieldname) as sAnswer FROM (tablename)", the answer suppose to be zero, but it turn out to be -1.77635683940025E-15.

I try with single precision field , it is correct. Is there anyway I can sum up double precision field correctly?
 
Nope. Not if you express the answer as a double.

That's binary maths for you.

Or more specfically, that's the problem with trying to represent decimal values in binary. The more precision you allow the more likely you are to run into such problems.

You could use the round()function on your sum and this will probably sort things out because you don't have a large number of values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top