# Bit numbering

### From Blackchocobo

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.

## Contents |

## LSB 0 bit numbering

When the bit numbering starts at zero for the least significant bit the numbering scheme is called "LSB 0". This bit numbering method has the advantage that for any unsigned integral data type the value of the number can be calculated by using exponentiation with the bit number and a base of 2.

## MSB 0 bit numbering

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

## 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".

their first bits and nibbles came from arithmetic logic unit|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 IBM System/360|S/360 and IBM System/370|370) and Hewlett-Packard (on the PA-RISC processor) consistently map zero to the MSB

The recommended style for Request for Comments documents is "MSB 0" bit numbering

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

Bit numbering is usually transparent to the software, but some programming languages like Ada (programming language)|Ada allow specifying the appropriate bit order for data type representation.

In computing, the **least significant bit** (**lsb**) is the bit position in a binary integer giving the units value, that is, determining whether the number is even or odd. The lsb is sometimes referred to as the *right-most bit*, due to the convention in positional notation of writing less significant digits further to the right. It is analogous to the least significant digit of a decimal integer, which is the digit in the *ones* (right-most) position.[1]

It is common to assign each bit a position number, ranging from zero to N-1, where N is the number of bits in the binary representation used. Normally, this is simply the exponent for the corresponding bit weight in base-2 (such as in `2`

). Although a few CPU manufacturers assign ^{31}..2^{0}**bit numbers** the opposite way (which is not the same as different endianness), the term *lsb* (of course) remains unambiguous as an alias for the unit bit.

By extension, the least significant bits (plural) are the bits of the number closest to, and including, the lsb.

The least significant bits have the useful property of changing rapidly if the number changes even slightly. For example, if 1 (binary 00000001) is added to 3 (binary 00000011), the result will be 4 (binary 00000100) and three of the least significant bits will change (011 to 100). By contrast, the three most significant bits stay unchanged (000 to 000).

Least significant bits are frequently employed in pseudorandom number generators, hash functions and checksums.

## Least significant byte

*LSB* (*lsb*) can also stand for **least significant byte**. The meaning is parallel to the above: it is the byte (or octet) in that position of a multi-byte number which has the least potential value.

In computing, the **most significant bit** (**msb**, also called the **high-order bit**) is the bit position in a binary number having the greatest value. The msb is sometimes referred to as the **left-most bit** due to the convention in positional notation of writing more significant digits further to the left.

The msb can also correspond to the sign of a signed binary number in one or two's complement notation. "1" meaning negative and "0" meaning positive.

It is common to assign each bit a position number, ranging from zero to N-1, where N is the number of bits in the binary representation used. Normally, this is simply the exponent for the corresponding bit weight in base-2 (such as in `2`

). Although a few CPU manufacturers assign ^{31}..2^{0}**bit numbers** the opposite way (which is not the same as different endianness), the *msb* unambiguously remain the *most* significant bit. This may be one of the reasons why the term *msb* is often used instead of a bit number, although the primary reason is probably that different number representations use different numbers of bits.

By extension, the **most significant bits** (plural) are the bits closest to, and including, the msb.

## Other uses

**MSB**, in all capitals, can also stand for "**most significant byte**". The meaning is parallel to the above: it is the byte (or octet) in that position of a multi-byte number which has the greatest potential value.

## Most significant byte

In computing, the **most significant bit** (**msb**, also called the **high-order bit**) is the bit position in a binary number having the greatest value. The msb is sometimes referred to as the **left-most bit** due to the convention in positional notation of writing more significant digits further to the left.

The msb can also correspond to the sign of a signed binary number in one or two's complement notation. "1" meaning negative and "0" meaning positive.

It is common to assign each bit a position number, ranging from zero to N-1, where N is the number of bits in the binary representation used. Normally, this is simply the exponent for the corresponding bit weight in base-2 (such as in `2`

). Although a few CPU manufacturers assign ^{31}..2^{0}**bit numbers** the opposite way (which is not the same as different endianness), the *msb* unambiguously remain the *most* significant bit. This may be one of the reasons why the term *msb* is often used instead of a bit number, although the primary reason is probably that different number representations use different numbers of bits.

By extension, the **most significant bits** (plural) are the bits closest to, and including, the msb.

## Other uses

**MSB**, in all capitals, can also stand for "**most significant byte**". The meaning is parallel to the above: it is the byte (or octet) in that position of a multi-byte number which has the greatest potential value.