Skip to content

Binary Counting

Bits

Bits in a byte are labelled 7 -> 0 with bit 7 being the most significant. Least significant is 0.

Two Byte Integer

It is a 16 bit unsigned integers in big-endian order. The high order byte precedes the lower order byte. This means a 16 bit word is presented as MSB then LSB.

Example: 17555

First Byte (MSB)

0 1 0 0 0 1 0 0
32768 16384 8192 4096 2048 1024 512 256

Least Significant Byte (LSB)

1 0 0 1 0 0 1 1
128 64 32 16 8 4 2 1
0100 0100 | 1001 0011

Four Byte Integer

Similar to two byte but using 32 bits instead of 16.

Example: 265,847,564

First Byte (MSB)

0 0 0 0 1 1 1 1
2,147,483,648 1,073,741,824 536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216

Second Byte

1 1 0 1 1 0 0 0
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536

Third Byte

1 0 0 0 0 0 1 1
32,768 16,384 8,192 4,096 2,048 1,024 512 256

Least Significant Byte (LSB)

0 0 0 0 1 1 0 0
128 64 32 16 8 4 2 1
0000 1111 | 1101 1000 | 1000 0011 | 0000 1100