This article may require cleanup to meet Wikipedia's quality standards. The specific problem is: The article is full of inaccuracies and mixes endianness with bit numbering. The article also implies that bit numbering is a property of the CPU; it is not. Mixes least significant byte with least significant bit, which have the same TLA. (May 2019)
In computing, bit numbering is the convention used to identify the bit positions in a binary number or a container of such a value. The bit number starts with zero and is incremented by one for each subsequent bit position.
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 low-order bit or 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.
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, the bit number is simply the exponent for the corresponding bit weight in base-2 (such as in 231..20). A few CPU manufacturers have assigned bit numbers the opposite way (which is not the same as different endianness). In any case, the least significant bit itself remains unambiguous as the unit bit.
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 (MSBs) stay unchanged (000 to 000). Because of this volatility, least significant bits are frequently employed in pseudorandom number generators, steganographic tools, hash functions and checksums.
In digital steganography, sensitive messages may be concealed by manipulating and storing information in the least significant bits of an image or a sound file. The user may later recover this information by extracting the least significant bits of the manipulated pixels to recover the original message. This allows the storage or transfer of digital information to remain concealed.
In computing, the most significant bit (MSB) is the bit position in a binary number having the greatest value. The MSB is sometimes referred to as the high-order bit or left-most bit due to the convention in positional notation of writing more significant digits further to the left.
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, the assigned bit number is simply the exponent for the corresponding bit weight in base-2 (such as in
231..20). A few CPU manufacturers assign bit numbers differently. Regardless of numbering, the MSB remains the most significant bit.
MSB can also stand for most significant byte. The meaning for bytes is parallel to that for bits: it is the byte of a multi-byte number which has the greatest potential value.
This table illustrates an example of decimal value of 149 and the location of LSB. In this particular example, the position of unit value (decimal 1 or 0) is located in bit position 0 (n = 0). MSB stands for most significant bit, while LSB stands for least significant bit.
|Binary (Decimal: 149)||1||0||0||1||0||1||0||1|
|Bit weight for given bit position n ( 2n )||27||26||25||24||23||22||21||20|
|Bit position label||MSB||LSB|
The position of the LSB is independent of the order bits are transmitted or stored, which is an endianness topic.
The expressions most significant bit first and least significant bit at last are indications on the ordering of the sequence of the bits in the bytes sent over a wire in a serial transmission protocol or in a stream (e.g. an audio stream).
Most significant bit first means that the most significant bit will arrive first: hence e.g. the hexadecimal number
00010010 in binary representation, will arrive as the sequence
0 0 0 1 0 0 1 0 .
Least significant bit first means that the least significant bit will arrive first: hence e.g. the same hexadecimal number
00010010 in binary representation, will arrive as the (reversed) sequence
0 1 0 0 1 0 0 0.
When the bit numbering starts at zero for the least significant bit (LSB) the numbering scheme is called "LSB 0". 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 therefore
where bi denotes the value of the bit with number i, and N denotes the number of bits in total.
Similarly, when the bit numbering starts at zero for the most significant bit (MSB) the numbering scheme is called "MSB 0".
The value of an unsigned binary integer is therefore
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 (typecast) to an array of Boolean ([ ]bool bits), the first element of this array (bits[lwb bits]) is again the "most significant bit".
For MSB 1 numbering, the value of an unsigned binary integer is
PL/I numbers BIT strings starting with 1 for the leftmost bit.
The Fortran BTEST function uses LSB 0 numbering.
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".
Bit numbering is usually transparent to the software, but some programming languages like Ada and hardware description languages like VHDL and verilog allow specifying the appropriate bit order for data type representation.
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
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
Whenever an octet represents a numeric quantity the left most bit in the diagram is the high order or most significant bit