working with Vars, decimal, hex and binary and how to compar
Posted: Sat Aug 20, 2016 11:53 am
OK you 8266 Basic Gurus, this noob is fuzzy on how I use decimal, Hex, and binary in a variable.
I am trying to do something really simple but I don't have any success.
If I wanted to see if a variable equals a hex value, how do you do it?
Want to see if pressed which is a var equals hex FF;
- none of these work:
if pressed <> HEX (FF) then print something
if pressed <> HEX ((FF)) then print something
if pressed <> 0xFF then print something
likewise, how do you set a vars value? Say I wanted to equate somevar equal to a hex value of A5?
somevar = 0xA5 doesn't work, somevar = HEX(A5) gives me 7FFFFFFFF
Then, how do you equate a variable to a binary number?
Say I wanted to equate or test a variable to 01010101?
Basically I want to equate any numeric variable to a decimal, hex, or binary value, compare a variable against any of these three.
Apologies if this is listed somewhere but I cannot find it in the docs or by perusing other work on this forum.
This is basic and should be easy??
I am trying to do something really simple but I don't have any success.
If I wanted to see if a variable equals a hex value, how do you do it?
Want to see if pressed which is a var equals hex FF;
- none of these work:
if pressed <> HEX (FF) then print something
if pressed <> HEX ((FF)) then print something
if pressed <> 0xFF then print something
likewise, how do you set a vars value? Say I wanted to equate somevar equal to a hex value of A5?
somevar = 0xA5 doesn't work, somevar = HEX(A5) gives me 7FFFFFFFF
Then, how do you equate a variable to a binary number?
Say I wanted to equate or test a variable to 01010101?
Basically I want to equate any numeric variable to a decimal, hex, or binary value, compare a variable against any of these three.
Apologies if this is listed somewhere but I cannot find it in the docs or by perusing other work on this forum.
This is basic and should be easy??