I get this code output on my Serial when the IR receiver gets a signal:
Protocol : GREE
Code : 0x01C02350000000E0 (64 Bits)
Mesg Desc.: Model: 1 (YAW1F), Power: Off, Mode: 1 (Cool), Temp: 16C, Fan: 0 (Auto), Turbo: Off, Econo: Off, IFeel: Off, WiFi: Off, XFan: Off, Light: On, Sleep: Off, Swing(V) Mode: Manual, Swing(V): 0 (Last), Swing(H): 0 (Off), Timer: 23:00, Display Temp: 0 (Off)
uint16_t rawData[279] = {...
When I convert 0x01C02350000000E0
to binary, however, it usually comes out to less than 64 bits. I'm assuming it has to do with the parameters of my IR receiver and not normal.
1 Answer 1
You are confusing the data size and the value size.
Yes, your value can be represented using fewer than 64 bits, but the data size that is used to contain that value is 64 bits in size.
It's like saying that "4" is stored in a 6 digit storage space. It only needs 1 storage slot, but the allocated space is 6 digits. So what is actually stored would be "000004".
As humans we tend to throw away the leading zeroes because they are meaningless. That's because we are able to use flexible storage sizes in our brains. The computer, though, works on fixed sizes - 8 bit, 16 bit, 32 bit, 64 bit, etc.
You can't store that value in a 32 bit variable, but you can in a 64 bit one. It may be wasteful for that specific value, but it's the smallest size that is available that is big enough.
0x01C02350000000E0
?When I convert 0x01C02350000000E0 to binary, however, it usually comes out to less than 64 bits
is like sayingwhen I add 2 plus 2, it usually comes out to 4
.... it either does, or it does not, there is no "usually"