3 ms·
It has 16 bits but the units of sizeof are not bytes – they are ‘the minimum difference between two addressable things’ which on that architecture is two bytes.
by dan-robertson 4y ago
It has 16 bits but the units of sizeof are not bytes – they are ‘the minimum difference between two addressable things’ which on that architecture is two bytes.
- tjoff 4y agoIsn't that a byte? So rather, a byte is 16 bits.
- actionfromafar 4y agoSure. A byte is two octets. In cases like these it pays to be very precise.
- rkangel 4y agoI can't remember the precise wording in the standard , but sizeof() is effectively "how many of the minimum addressable thing do you need to store this thing". The "minimum addressable thing" is called a byte, and on XAP that is a 16-bit value. Storing a uint8_t wastes a 8 bits, because there isn't anything smaller than an int to put it in.
- magicalhippo 4y agoRight, I was assuming the bytes were 8 bits[1] given sizeof(uint8_t) == 1, ie since it had uint8_t. Seems really weird to have uint8_t but have CHAR_BIT > 8. [1]: https://en.cppreference.com/w/c/language/sizeof https://en.cppreference.com/w/c/language/sizeof