Page 1 of 1
math question
Posted: Sat Sep 11, 2004 2:28 am
by J. Baker
Going through the PureBasic help and came across this.
b = 4 * (2 - (3 - 4))
It says this equals 12 but to me it seems this should equal -4.
Could some one explain why this equals 12?
Here's how I got -4.
b = 4 * (2 - (3 - 4))
b = 4 * (2 - (1))
b = 4 * (-1)
b = -4
Posted: Sat Sep 11, 2004 2:51 am
by Dare2
Depends how you evaluate PosVal - NegVal
Maybe
b = 4 * (2 - (3 - 4))
b = 4 * (2 - ( - 1 ))
b = 4 * (2 - - 1)
b = 4 * (3)
b = 12
Edit:
Ie, like signs always add and unlike always subtract
Re: math question
Posted: Sat Sep 11, 2004 3:01 am
by jack
b = 4 * (2 - (3 - 4))
b = 4 * (2 - (1))
b = 4 * (-1)
b = -4
(3-4) --> -1
2-(-1)--> 3
4*3-->12
Posted: Sat Sep 11, 2004 3:12 am
by J. Baker
That still don't make sense.
3 - 4 = 1, now if it were 4 - 3, then it would be -1.
Also, 2 - (-1) is -3.
Posted: Sat Sep 11, 2004 3:16 am
by J. Baker
AHHHHH, I'm thinking backwards. LOL
Posted: Sat Sep 11, 2004 6:33 am
by blueznl
b = 4 * (2 - (3 - 4))
b = 4 * ( 2 - ( -1 ) ) <=>
b = 4 * ( 2 + 1 ) <=>
b = 4 * 3 <=>
b = 12
Posted: Sun Sep 12, 2004 5:27 am
by Dare2
J. Baker wrote:AHHHHH, I'm thinking backwards. LOL
Hehe.

Big-Endian -v- Little-endian? or FIFO -v- LIFO?
Posted: Sun Sep 12, 2004 5:51 am
by J. Baker
LOL, I guess that'll happen when you get four hours sleep in fourty-eight hours. Oh well, it's not the first and probably won't be the last.
