# Bit numbering

Jump to: navigation, search

In computing, bit numbering (or sometimes bit endianness) is the convention used to identify the bit positions in a binary number or a container for such a value. The bit number starts with zero and is incremented by one for each subsequent bit position.

## LSB 0 bit numbering

LSB 0: A container for 8-bit binary number with the highlighted least significant bit assigned the bit number 0

When the bit numbering starts at zero for the least significant bit the numbering scheme is called "LSB 0".[1] This bit numbering method has the advantage that for any unsigned number the value of the number can be calculated by using exponentiation with the bit number and a base of 2. The value of an unsigned binary integer is

$\sum_{i=0}^{N-1} a_i \cdot 2^i$

where ai denotes the value of the bit with number i and N denotes the number of bits in total.

## MSB 0 bit numbering

MSB 0:A container for 8-bit binary number with the highlighted most significant bit assigned the bit number 0

Similarly, when the bit numbering starts at zero for the most significant bit the numbering scheme is called "MSB 0".

## Other

ALGOL 68's elem operator is effectively "MSB 1 bit numbering" as the bits are numbered from left to right with the first bit (bits elem 1) being the "most significant bit" and the expression (bits elem bits width) giving the "least significant bit". Similarly when bits are coerced (cast) to an array of Boolean ([]bool bits) the first element of this array (bits[lwb bits]) is again the "most significant bit".

## Usage

Little-endian CPUs usually employ "LSB 0" bit numbering, however both bit numbering conventions can be seen in big-endian machines. Some architectures like SPARC and Motorola 68000 use "LSB 0" bit numbering, while S/390, PowerPC and PA-RISC use "MSB 0".[2]

The recommended style for Request for Comments documents is "MSB 0" bit numbering.[3][4]

Bit numbering is usually transparent to the software, but some programming languages like Ada allow specifying the appropriate bit order for data type representation.[5]

## References

1. ^ Langdon, Glen G. (1982). Computer Design. Computeach Press Inc. p. 52. ISBN 0-9607864-0-6.
2. ^ David V. James (June 1990). "Multiplexed buses: the endian wars continue". IEEE Micro 10 (3): 9–21. doi:10.1109/40.56322. ISSN 0272-1732. Retrieved 2008-12-20. "their first bits and nibbles came from ALU chips, which map zero (0) to the least significant bit. (...) some (otherwise) big-endian designers insist on using the little-endian notation to describe bits and the big-endian notation to describe bytes. (...) Note that IBM (on the S/360 and 370) and Hewlett-Packard (on the PA-RISC processor) consistently map zero to the MSB"
3. ^ Scott, Gregor (June 1998). "RFC 2360 - Guide for Internet Standards Writers". Internet Engineering Task Force (IETF). p. 11. Retrieved 2010-02-14. "The preferred form for packet diagrams is a sequence of long words in network byte order, with each word horizontal on the page and bit numbering at the top"
4. ^ "RFC 1166 - INTERNET NUMBERS". Internet Engineering Task Force (IETF). July 1990. p. 1. Retrieved 2014-06-11. "Whenever an octet represents a numeric quantity the left most bit in the diagram is the high order or most significant bit"
5. ^ Norman H. Cohen (January 1994). "Endian-independent record representation clauses". Ada Letters (ACM SIGAda) XIV (1): 27–29. doi:10.1145/181492.181493. ISSN 1094-3641. Retrieved 2008-12-20.