For everything that's not in any way related to PureBasic. General chat etc...
-
J. Baker
- Addict

- Posts: 2192
- Joined: Sun Apr 27, 2003 8:12 am
- Location: USA
-
Contact:
Post
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
-
Dare2
- Moderator

- Posts: 3321
- Joined: Sat Dec 27, 2003 3:55 am
- Location: Great Southern Land
Post
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
@}--`--,-- A rose by any other name ..
-
jack
- Addict

- Posts: 1358
- Joined: Fri Apr 25, 2003 11:10 pm
Post
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
-
J. Baker
- Addict

- Posts: 2192
- Joined: Sun Apr 27, 2003 8:12 am
- Location: USA
-
Contact:
Post
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.
-
J. Baker
- Addict

- Posts: 2192
- Joined: Sun Apr 27, 2003 8:12 am
- Location: USA
-
Contact:
Post
by J. Baker »
AHHHHH, I'm thinking backwards. LOL
-
blueznl
- PureBasic Expert

- Posts: 6172
- Joined: Sat May 17, 2003 11:31 am
-
Contact:
Post
by blueznl »
b = 4 * (2 - (3 - 4))
b = 4 * ( 2 - ( -1 ) ) <=>
b = 4 * ( 2 + 1 ) <=>
b = 4 * 3 <=>
b = 12
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide
right here... )
-
Dare2
- Moderator

- Posts: 3321
- Joined: Sat Dec 27, 2003 3:55 am
- Location: Great Southern Land
Post
by Dare2 »
J. Baker wrote:AHHHHH, I'm thinking backwards. LOL
Hehe.

Big-Endian -v- Little-endian? or FIFO -v- LIFO?
@}--`--,-- A rose by any other name ..
-
J. Baker
- Addict

- Posts: 2192
- Joined: Sun Apr 27, 2003 8:12 am
- Location: USA
-
Contact:
Post
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.
