0

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.

3
  • 1
    sixteen hexadecimal digits equals 64 binary digits ... that is what fits into eight bytes of data ....... what binary number do you get from 0x01C02350000000E0?
    – jsotola
    Dec 14, 2021 at 17:11
  • 2
    I don't really understand the question. 0x01C02350000000E0 is a 16-digit hexadecimal number and so directly translates to 16x4 = 64 bits. What do you mean that it "usually" comes out as less than that? Do you not count the leading zeroes? They are bits as well.
    – StarCat
    Dec 14, 2021 at 17:13
  • 1
    When I convert 0x01C02350000000E0 to binary, however, it usually comes out to less than 64 bits is like saying when I add 2 plus 2, it usually comes out to 4 .... it either does, or it does not, there is no "usually"
    – jsotola
    Dec 14, 2021 at 17:17

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.