Page 1 of 1
More than
Posted: Mon Oct 10, 2011 2:36 pm
by Electric Sheep
Can anybody tell me why the output is different when they look similar...
Code: Select all
a.i = 20
b.i = 30
Debug a - (a > b) ; output is -10
Debug 20 - (20>30) ; output is 20
Re: More than
Posted: Mon Oct 10, 2011 2:44 pm
by srod
PB does not support this use of the logical operators.
Re: More than
Posted: Mon Oct 10, 2011 2:56 pm
by luis
You can maybe approximate what you wanted with this hack:
Code: Select all
Macro BOOL (exp)
; a = 15
; Debug (a = 15) ; prints 15
; Debug BOOL(a = 15) ; prints 1 (#True)
(1 And (exp))
EndMacro
a.i = 20
b.i = 30
Debug a - BOOL(a < b) ; 19
Debug a - BOOL(a > b) ; 20
Debug 20 - BOOL(20 < 30) ; 19
Debug 20 - BOOL(20 > 30) ; 20
See also:
http://www.purebasic.fr/english/viewtop ... 31#p303631
Re: More than
Posted: Mon Oct 10, 2011 3:07 pm
by Electric Sheep
Thanks luis.
This seems to fix it...
Code: Select all
a.i = 20
b.i = 30
Debug a - (a > b And 1) ; output is 20
Debug 20 - (20>30 And 1) ; output is 20