Overview
A binary digit or bit is a 0
or 1
character. A bit string is then a contiguous sequence of bits. It’s weight is a reference to the number of 1
s in the bit string. Compare the below operation to the method for converting from one numerical base to another (e.g. hexadecimal).
Endianness
Platforms with multi-byte objects must establish the object’s address and byte ordering. Objects are typically addressed by the smallest address of the bytes used. Bytes are ordered either in big-endian or little-endian. In big-endian, the most significant byte is listed first. In little-endian, the least significant byte is ordered first.
The above snippet can be used to check endianness on the current machine. If big-endian, the output should be 01 23 45 67
. If little-endian, 67 45 23 01
.
Bibliography
- Bryant, Randal E., and David O’Hallaron. Computer Systems: A Programmer’s Perspective. Third edition, Global edition. Always Learning. Pearson, 2016.