Get the value from hex

Get the value from hex

*here is the question link :

and now think about, how it works.

you get this number : 1427709952 and you should parse it like that.

< byte3 byte 2 byte 1 byte 0 >
Motor  indoor  outdoor  not in use


it is an integer value and the hex value of it is : 0x55192000. so if we parse it 0x55 : 85 , 0x19 : 25 , 0x20: 32. 

now we are doing it programmatically.

float motor=(float)((temp&0xff000000)»24); float indoor=(float)((temp&0x00ff0000)»16); float outdoor=(float)((temp&0x0000ff00)»8);

24,26 and 8 are the numbers of bits to shift. »8 means shift one byte, »24 means shift three byte, and you know an integer value is four byte. after shifting we do AND operation and get the values.