thanks..
All data stored in memory is in binary (BIN). Hex is a representation of the binary that humans can read.
To print a hex number in binary
Serial.println(0x25, BIN);
To print a binary number in hex
Serial.print(0b00101100, HEX);
So if i have a parameter y for example
And i see it on the screen as a HEX values
Can i write something like this :
if(y>1111)
Some code
It will work????
if(y>1111)
The 1111 will be seen as a decimal integer
if(y>0x1111)
The 0x prefix indicates that it is a HEX number
So i do not understand..
How do i compare a bin number ?
Like if y is a binary parameter and stores a binary info ...
How could i write an if statement??
if(y<0x250011)
....
????
To put a binary number in a program, use the 0b prefix
if (y < 0b01011010)
[edit] that's exactly the same as putting
if (y < 90) //decimal
or
if (y < 0x5A) //hex
You don't have to do anything to y to do these comparisons. y is just a quantity. It doesn't have a base until you try to print it out etc.
how do you compare a BIN number to what?
do you want to compare a BIN to a HEX, or a BIN to a BIN?
are you looking for arithmetic comparisons, or bitwise comparison?
As previously stated, EVERYTHING stored in the processor is binary. BIN, HEX, ASCII, Decimal, etc are just different ways of presenting the same information in human-readable form.