subtracting negative numbers

C

CK

I just started working with access and having issue with calculating a total.
For example in a query I am attempting to calculate the results of Column A
- Column B but the resulting (Result) is not what I was expecting (Expected).
Can someone help me shed light on this. I want to show the variance between
the numbers.

Column A Column B Result Expected
0 -100 100
-100
100 -100 200
0
100 50 150
-50

Is there anyway to at lease get column b to subtract from column a and
report it as the results.... seems like all it does is add it. I have tried
this with currancy (-$1.00) and Integers also.... don't get it.
 
D

Douglas J. Steele

No offense, but I think you need to review the rules of arithmetic!

0 - (-100) does equal 100, 100 - (-100) does equal 200. The last one doesn't
make sense, though: 100 - 50 is 50.
 
R

RBear3

Well, 0 - (-100) is indeed 100.

100 - (-100) is 200.


You need to be ADDING the two columns, not subtracting.

Subtracting a NEGATIVE number actually adds it. This is basic math.


Now, your third example does not make sense. You can't have it both ways.
Either enter the values in column B as a positive number, then subtract it
from column A. If the result is A - B, then the third example should result
in 50. You say you expect a result of -50? How? 100-50=50.

Your math is messed up.
 
J

John

CK said:
Is there anyway to at lease get column b to subtract from column a and
report it as the results.... seems like all it does is add it. I have tried
this with currancy (-$1.00) and Integers also.... don't get it.

No, actually it is subtracting it. Two negatives makes a positive, so
subtracting a negative number is the same thing as adding a positive
number. That is,

100 - (-100) = 100 + 100 = 200

Are all of the values in column B negative? If so, then *adding* the two
together would give you the expected result. That is,

100 + (-100) = 100 - 100 = 0

The other thing you might try is subtracting the absolute value of
column B, but that might not give you exactly what you're looking for,
depending on what you're trying to do:

100 - Abs(-100) = 100 - Abs(100) = 100 + (-100) = 100 - 100 = 0
 
D

Duane Hookom

Subtracting a negative number is the same as adding a positive. Perhaps you
want to simply add them.
 
T

tkelley via AccessMonster.com

Just paste in the code ... along with the data types of the columns in
question.
 
L

Lord Kelvan

you know whats good to ask what is the context of the data why are you
subtracting numbers as the others have said it is basic maths
- by - = +
- by + = -
+ by + = +

what is columna and columnb and what are you trying to achieve
 
T

tkelley via AccessMonster.com

Without the code you're using, there is no context. And this just continues
as a discussion on mathematic principles. I'm out. Good luck.
Just paste in the code ... along with the data types of the columns in
question.
[quoted text clipped - 16 lines]
100 - Abs(-100) = 100 - Abs(100) = 100 + (-100) = 100 - 100 = 0
 

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