Negative zero result from decimal calculations

C

cmpf

Was getting some interesting results coming out of some calculations in
access. To use a specific example, had the numbers 1.75 and 1.7.
Subtracting the two yielded .04999999999999. Displaying the Rounded numbers
later in a report then showed that 1.8 minus 1.7 = 0. Not ideal.

I fixed this by using a custom function based on the CDec vb function. Now
1.75 - 1.7 equals 0.05. Hurrah!

Unfortunately, 1.7-1.7 now seems to equal -0. Not 0. -0. Well, I should
clarify, it looks like 0 in the query, but when it is exported or accessed
elsewhere (i.e. excel) its passing through a -0. CDbl on the result yields
an Error. nz works, but changes blanks/nulls to zero as well, which I don't
want in this case. Any suggestions or insights?
 
T

TonyT

Hi cmpf,

What custom function did you use?

Better to use CDbl rather than CDec due to the inherent problems with
decimal data types - just search in here for plenty of examples.

TonyT..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top