Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

2020/4/10 Bit numbering - Wikipedia

Bit numbering
In computing, bit numbering (or sometimes bit endianness) 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.

Contents
Least significant bit
Least significant bit in digital steganography
Least significant byte
Most significant bit
Most significant byte
Unsigned integer example
Most- vs least-significant bit first
LSB 0 bit numbering
MSB 0 bit numbering
Other
Usage
See also
References
External links
Least significant bit
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 binary representation of decimal 149,
The LSB is sometimes referred to as the low-order bit or
with the LSB highlighted. The MSB in an 8-
right-most bit, due to the convention in positional bit binary number represents a value of 128
notation of writing less significant digits further to the
right. It is analogous to the least significant digit of a
decimal. The LSB represents a value of 1.
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 231..20). Although a few CPU manufacturers assign bit numbers the
opposite way (which is not the same as different endianness), the term least significant bit itself
remains unambiguous as an alias for the unit bit.

https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit 1/6
2020/4/10 Bit numbering - Wikipedia

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 (MSBs) stay unchanged (000 to 000).

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

Least significant bit in digital steganography


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. In the
context of an image, if a user were to manipulate the last
two bits of a color in a pixel, the value of the color would
change at most ±3 value places, which is likely to be
indistinguishable by the human eye. 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.

Least significant byte


LSB can also stand for least significant byte.[2] 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. If the
abbreviation's meaning least significant byte isn't obvious from context, it should be stated explicitly
to avoid confusion with least significant bit.

To avoid this ambiguity, the less abbreviated terms "lsbit" or "lsbyte" may be used.

Most significant bit


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 high-order bit
or 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 bit of a signed binary number. In one's and two's
complement notation, "1" signifies a negative number and "0" signifies a positive number.

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 231..20). Although a few CPU manufacturers assign bit numbers the
opposite way (which is not the same as different endianness), the MSB unambiguously remains 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.

https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit 2/6
2020/4/10 Bit numbering - Wikipedia

Most significant byte


MSB can also stand for "most significant byte".[3]
The meaning is parallel to the above: it is the byte (or The unsigned binary representation of
octet) in that position of a multi-byte number which has decimal 149, with the MSB highlighted. The
the greatest potential value. MSB in an 8-bit binary number represents a
value of 128 decimal. The LSB represents a
To avoid this ambiguity, the less abbreviated terms value of 1.
"MSbit" or "MSbyte" are often used.[4][5][6]

Unsigned integer example


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
Position of LSB is independent of how the bit position is transmitted (Some system transmit MSB
first, others transmit LSB first), which is a question more of a topic of Endianness.

Most- vs least-significant bit first


The expressions most significant bit first and least significant bit first are indications on the ordering
of the sequence of the bits in the bytes sent over a wire in a 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 0x12, 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 0x12, again 00010010 in binary representation, will arrive as the (reversed)
sequence 0 1 0 0 1 0 0 0.

LSB 0 bit numbering


When the bit numbering starts at zero for the least
significant bit (LSB) the numbering scheme is called
"LSB  0".[7] This bit numbering method has the
advantage that for any unsigned number the value of
the number can be calculated by using LSB 0: A container for 8-bit binary number
exponentiation with the bit number and a base of 2. with the highlighted least significant bit
The value of an unsigned binary integer is therefore assigned the bit number 0

https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit 3/6
2020/4/10 Bit numbering - Wikipedia

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

MSB 0 bit numbering


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


MSB 0: A container for 8-bit binary number
with the highlighted most significant bit
assigned the bit number 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 (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.

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".[8]

The recommended style for Request for Comments (RfC) documents is "MSB 0" bit numbering.[9][10]

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.[11]

See also
ARINC 429
Binary numeral system
Signed number representations
Two's complement
https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit 4/6
2020/4/10 Bit numbering - Wikipedia

Endianness
Binary logarithm
Unit in the last place (ULP)
Find first set
MAC address: Bit-reversed notation
References
1. "IBM SNA Formats Bit Ordering is Opposite of Intel Convention" (https://support.microsoft.
com/en-us/kb/130861). Microsoft. 2014-02-23.
2. Buczynski, Don (2002-09-05). "MSB/LSB Tutorial" (http://www.buczynski.com/Proteus/ms
blsb.html).
3. Rouse, Margaret (September 2005). "most significant bit or byte" (http://whatis.techtarget.
com/definition/most-significant-bit-or-byte). TechTarget.
4. II, Patrick J. Sweeney (2010-03-11). RFID For Dummies (https://books.google.com/?id=Gb6
w54X7Kw0C&pg=PA370&lpg=PA370&dq=%22msbit%22++%22msbyte%22#v=onepage&q
=%22msbit%22%20%20%22msbyte%22&f=false). John Wiley & Sons.
ISBN 9781118054475.
5. "Amulet Bitmap Format" (http://web.mit.edu/6.115/www/amulet/Bitmap.htm). web.mit.edu.
Retrieved 2018-02-25.
6. "Memory MAYHEM! Memory, Byte Ordering and Alignment" (https://www.cs.umd.edu/~mee
sh/cmsc411/website/projects/outer/memory/memory.htm). www.cs.umd.edu. Retrieved
2018-02-25.
7. Langdon, Glen G. (1982). Computer Design (https://archive.org/details/computerdesign00la
ng/page/52). Computeach Press Inc. p. 52 (https://archive.org/details/computerdesign00la
ng/page/52). ISBN 0-9607864-0-6.
8. David V. James (June 1990). "Multiplexed buses: the endian wars continue". IEEE Micro. 10
(3): 9–21. doi:10.1109/40.56322 (https://doi.org/10.1109%2F40.56322). ISSN 0272-1732 (ht
tps://www.worldcat.org/issn/0272-1732). "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"
9. Scott, Gregor (June 1998). "RFC 2360 - Guide for Internet Standards Writers" (http://tools.i
etf.org/html/rfc2360). 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"
10. "RFC 1166 - INTERNET NUMBERS" (http://tools.ietf.org/html/rfc1166). 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"
11. Norman H. Cohen (January 1994). "Endian-independent record representation clauses" (htt
p://researchweb.watson.ibm.com/people/n/ncohen/EndianIndepRecRepClauses.pdf) (PDF).
Ada Letters. ACM SIGAda. XIV (1): 27–29. doi:10.1145/181492.181493 (https://doi.org/10.114
5%2F181492.181493). ISSN 1094-3641 (https://www.worldcat.org/issn/1094-3641).
Retrieved 2008-12-20.
External links
Bit Numbers (http://www.xcprod.com/titan/XCSB-DOC/bit_numbers.html)
Bit numbering for different CPUs:
https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit 5/6
2020/4/10 Bit numbering - Wikipedia

Motorola 68000 (https://web.archive.org/web/20041029235810/http://developer.apple.


com/documentation/mac/OSUtilities/OSUtilities-39.html) ("Bit manipulation" and
"Reversed Bit-Numbering" sections)
IBM Cell Broadband Processors (http://publib.boulder.ibm.com/infocenter/systems/sco
pe/syssw/index.jsp?topic=/eiccj/tutorial/cbet_1byteorder.html) ("Byte ordering and bit
numbering")
Retrieved from "https://en.wikipedia.org/w/index.php?title=Bit_numbering&oldid=938170411#Least_significant_bit"

This page was last edited on 29 January 2020, at 15:13 (UTC).


Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using
this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia
Foundation, Inc., a non-profit organization.

https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit 6/6

You might also like