Page 1 of 1

ABS & NOT

Posted: Tue Oct 08, 2019 12:38 am
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 5553 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]

Re: ABS & NOT

Posted: Tue Oct 08, 2019 4:02 am
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

...