Query from MDB returns "-0" value

K

Kamil

Hi.
I have a summary query which is summarizing some +/- values from a
table. So the result can be positive or negative number or zero.
I'm downloading the query results via ODBC to Excel.

It happens that I have value "-0" which seems to be correct to excel
(I can add 1 to it, and have 1 in result) but is not equal to 0 (-0=0 -

Do you know the problem? Is it matter of some settings, or I have to
use some formula in my access query?

Best regards,
Kamil
 
A

Allen Browne

There are several reasons why a number could display as negative zero, e.g.:
a) a miniscule value that's too small to display any other way
b) formatting that's displaying a rounded result
c) faulty formatting
d) it's actually being treated as Text, not a number.
 
J

John W. Vinson

Hi.
I have a summary query which is summarizing some +/- values from a
table. So the result can be positive or negative number or zero.
I'm downloading the query results via ODBC to Excel.

It happens that I have value "-0" which seems to be correct to excel
(I can add 1 to it, and have 1 in result) but is not equal to 0 (-0=0 -

Do you know the problem? Is it matter of some settings, or I have to
use some formula in my access query?

Best regards,
Kamil

Boy, this takes me back forty years to my FORTRAN II days...

This probably has to do with the way integers are stored in binary form. They
are stored in "twos complement" form (see
http://en.wikipedia.org/wiki/Twos_complement for a discussion). Access Long
Integers are 32-bit numbers, but for the example let's pretend they are 8 bit.
+1 is stored as 00000001; -1 is stored as the twos complement, 11111110. The
largest positive number is 01111111 (127 in this 8-bit math), whereas 10000000
is -128.

The one anomaly of this is that there are TWO bitstrings which correspond to
zero: 00000000 and 11111111. The latter is -0, and it's clearly not equal to 0
(every bit is different!!), but adding 1 to it does indeed give 00000001. You
can get -0 as the result of certain sequences of addition and subtraction. I
haven't seen it happen in Access but I remember having to trap for it in
FORTRAN.
 

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