ABS & NOT

Questions about the BASICtools and MakeItC
Post Reply
olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

ABS & NOT

Post by olzeke51 »

not a biggie - probably my not understanding 'expression'??
was trying to toggle/flip a value between 0 and 1 upon each keypress
'
so I used ABS of a NOT value ABS (NOT toggled) and got an incrementing value !!
abs_not.jpg
abs_not.jpg (95.96 KiB) Viewed 8755 times
'
any thoughts -- - on the ABS(NOT ) situation???
Olzeke51
EDIT - print NOT 2 will show a -3 [??? negative 1's compliment ??]
print NOT -3 will show a 2


PS. Blinky used an AND 1 to flip the IO(led) - but it also increments the value [which I don't want]



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: ABS & NOT

Post by basicchip »

Logical and bitwise expressions in BASIC use the same named function. It depends on context which one gets applied.

toggled = 1

bitwise NOT toggled = &HFFFFFFFE

ABS (&HFFFFFFFE) = 2 ' because &HFFFFFFE = -2

bitwise NOT 2 = &HFFFFFFFD ' which = -3

so ABS (-3) = 3

...

Post Reply