What it does
Every bit of a binary number has a weight, and documents disagree about what to call each one. The least significant bit (LSB) is the one worth 1, the most significant bit (MSB) the one worth the most, and the three numberings in use count from different ends or from a different first number. The page answers the questions that follow, in three modes:
- Value. A number and its width: every bit with its weight and its number under LSB 0, MSB 0 and 1-based numbering, the set bits under each, the count of ones and the parity bit, the lowest and highest set bits, the two's complement reading, the value with its bits reversed, octet by octet and whole, the octets swapped, and the order the bits take on a link that sends the least significant bit first and on one that sends the most significant first. Optionally a known layout names every field, and "bits i to j" in any numbering gives the field's mask, shift and value.
- Printed bits. A string of 0s and 1s as a device printed it, with the order it was printed in: the value it stands for, and the value the same string gives if it is read the other way.
- MAC address. A 48-bit Media Access Control (MAC) address written in canonical form or bit-reversed: both forms, the I/G (individual/group) and U/L (universal/local) bits, the quadrant of a local address under the Structured Local Address Plan (SLAP), and the 48 bits in the order an Ethernet link sends them.
Everything is computed in your browser.
The three numberings
- LSB 0: bit 0 is the least significant, so bit k is worth 2 to the power k. Intel's manual puts it in one sentence: "Bit positions are numbered from right to left. The numerical value of a set bit is equal to two raised to the power of the bit position" (Intel SDM volume 1, 1.3.1). The Linux kernel writes masks the same way,
BIT(nr)as1 << nrandGENMASK(h, l)as "a contiguous bitmask starting at bit position @l and ending at position @h" (include/linux/bits.h). - MSB 0: bit 0 is the most significant. Every RFC (Request for Comments) diagram uses it: "the bit labeled 0 is the most significant bit", so the octet drawn
1 0 1 0 1 0 1 0is 170 (RFC 791, Appendix B). IBM's z/Architecture numbers its registers this way too: in 24-bit addressing mode "bits 0-39 of the intermediate value are ignored" (IBM SA22-7832-13). - 1-based: bit 1 is the least significant. The Simple Network Management Protocol (SNMP) places a BITS value in "bits 8 (high order bit) to 1 (low order bit)" of each octet (RFC 3417, section 8), and Huawei's
display eth-trunkdocuments its LACP PortState as Bit 1 to Bit 8 (Huawei, Link Aggregation Commands).
In a width of w bits, LSB 0 bit k is MSB 0 bit w - 1 - k and 1-based bit k + 1. The page shows all three for every bit, so a number read from one document can be found in another.
Value: the inputs
- Value: hexadecimal with
0x(0x3D), binary with0b(0b0011_1101), or decimal digits (61); single spaces or underscores may separate groups of digits. A minus sign before a decimal gives its two's complement bits. A string of hex digits without0xis refused with a hint, so10is never silently ten or sixteen. - Width: 1 to 64 bits. Left blank, it comes from the input: four bits for each hexadecimal digit and one for each binary digit, leading zeros included (so
0x0800is 16 bits), or the smallest of 8, 16, 32 and 64 that holds a decimal value. - Layout (optional), for a value of the layout's width:
- LACP state (8 bits): the Actor_State or Partner_State octet of the Link Aggregation Control Protocol (LACP). The Institute of Electrical and Electronics Engineers (IEEE) standard 802.1AX numbers the bits 0 (LACP_Activity) to 7 (Expired) (IEEE8023-LAG-MIB), the Linux driver's masks run from
0x1to0x80(if_bonding.h), and Huawei prints the same bits as Bit 1 to Bit 8. - MAC first octet (8 bits): "The least significant bit of Octet 0 (the I/G bit)" and "the second least significant bit of Octet 0 (the U/L bit)" (IEEE RA guidelines), with the Y and Z bits that RFC 9542 draws above them (section 2.1).
- TCP flags (8 bits): the header's fourteenth octet, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN (RFC 9293, section 3.1). The Internet Assigned Numbers Authority (IANA) numbers them 8 to 15 in its TCP Header Flags registry (IANA), Linux
BIT(7)toBIT(0)(include/net/tcp.h). - DNS flags (16 bits): the second word of the Domain Name System (DNS) header, QR, Opcode, AA, TC, RD, RA, Z, AD, CD and RCODE as RFC 1035 (section 4.1.1) and RFC 6895 (section 2) draw them; IANA's DNS Header Flags registry numbers AA bit 5 to CD bit 11 (IANA).
- IPv4 ToS (8 bits): the Type of Service octet, the IPv6 Traffic Class: the differentiated services codepoint (DSCP) in bits 0 to 5 (RFC 2474, section 3) and Explicit Congestion Notification (ECN) in "Bits 6 and 7" (RFC 3168, section 5), with the ECN codepoint named.
- 802.1Q TCI (16 bits): the tag's priority, DEI (Drop Eligible Indicator) and VLAN (virtual local area network) ID, with the Linux kernel's masks
0xe000(shift 13),0x1000and0x0fff(include/linux/if_vlan.h).
- LACP state (8 bits): the Actor_State or Partner_State octet of the Link Aggregation Control Protocol (LACP). The Institute of Electrical and Electronics Engineers (IEEE) standard 802.1AX numbers the bits 0 (LACP_Activity) to 7 (Expired) (IEEE8023-LAG-MIB), the Linux driver's masks run from
- Bits i to j (optional): a numbering and one or two bit numbers. The field's mask, shift, value, the C expression
(v >> shift) & maskand the kernel'sGENMASK(hi, lo)(orBIT(n)for one bit), and the same bits under the other two numberings.
Value: the rules
- Two's complement. The value read as a signed number is negative when its top bit is set; for 8, 16, 32 and 64 bits Intel's sentence applies: "The sign bit is located in bit 7 in a byte integer, bit 15 in a word integer, bit 31 in a doubleword integer, and bit 63 in a quadword integer" (Intel SDM, 4.2.1.2).
- Lowest and highest set bit. In LSB 0 numbers, what Intel's BSF and BSR instructions return: "the offset from the least significant bit (bit 0) in the bit string to the first set bit" (7.3.7.2).
- Parity. Even parity adds the bit that makes "an even number of logic 1s in the data and parity bits", odd parity the bit that makes it odd (TI TL16C550D, line control register bit 4).
- Reversal. "All bits reversed" mirrors the whole width; "Bits reversed in each octet" mirrors each octet in place, the swap RFC 2469 describes between canonical and Token Ring addresses; "Octets swapped" is byte order, which Big-endian and little-endian explains. Mirroring the whole width is the other two together. The Linux kernel's own CRC-32, a cyclic redundancy check (CRC), shows a reversal: the same polynomial is
0x04c11db7most significant bit first and0xedb88320least significant bit first (include/linux/crc32.h). - On the wire. For whole octets, the bits in the order a link sends them, octet by octet, the octets in the order written (most significant first, as network byte order sends a number, RFC 791). Least significant bit first is Ethernet's order, the reverse of what the Internet Engineering Task Force (IETF) draws: "the physical order of bit transmission within an octet on an IEEE [802.3] link is from the lowest order bit to the highest order bit (i.e., the reverse of the IETF's ordering)" (RFC 9542, section 1.1); a UART (universal asynchronous receiver-transmitter) does the same, "Bit 0 is the least significant bit. It is the first bit serially transmitted or received" (TI TL16C550D), and the Point-to-Point Protocol (PPP): "All octets are transmitted least significant bit first" (RFC 1662, sections 4.5.2 and 5.5). Most significant bit first is the rule of an I2C bus, "Data is transferred with the Most Significant Bit (MSB) first" (NXP UM10204, 3.1.5), and the default of a Serial Peripheral Interface (SPI) bus, "the 'MSB first' default for each word in a transfer", which a device can change with
SPI_LSB_FIRST(include/linux/spi/spi.h).
Printed bits
Type the bits in the order they are printed and say which end comes first. Most significant bit first is the order numbers are written in. Least significant bit first is how Huawei prints an LACP PortState: its command reference describes "The status variable is eight bits, such as 10111100" as Bit 1 to Bit 8, in the order of 802.1AX's bits 0 to 7, so its first character is LACP_Activity, the bit of weight 1, and 10111100 is the octet 0x3D (Huawei, Table 5-17). Read the other way, the same string would be 0xBC, and the page shows both, because a misread order changes the number without any error. The value's whole reading follows, with the LACP state layout if you choose it.
MAC address
- Canonical form is how RFC 2469 defines an address for display: "The first bit of each byte that appears on the LAN maps to the least significant (i.e., right-most) bit of each byte in memory", which "puts the group address indicator ... in the least significant bit of the first byte". Ethernet hardware works this way.
- Bit-reversed form ("MSB format", "non-canonical form") is how Token Ring and some FDDI (Fiber Distributed Data Interface) adapters held addresses: each octet with its bits reversed, so 12-34-56-78-9A-BC sat in memory as 48-2C-6A-1E-59-3D. Choose the form the address was written in; the page gives the other.
- I/G and U/L. From the canonical first octet: I/G 0 for one station, 1 for a group (multicast or broadcast); U/L 0 for an address under an IEEE-assigned prefix, 1 for a local one (IEEE RA guidelines; RFC 9542). The Linux kernel tests them as
0x01 & addr[0]and0x02 & addr[0](include/linux/etherdevice.h). - SLAP quadrant. For a local address, the Y and Z bits pick one of four quadrants: Administratively Assigned (Y 0, Z 0), Extended Local (Y 0, Z 1), Reserved (Y 1, Z 0) and Standard Assigned (Y 1, Z 1) (RFC 9542, section 2.1.1, Table 2); the plan is optional.
- On the wire. The 48 bits octet by octet, each least significant bit first, so the first bit sent is the I/G bit.
- The misread line shows what a reader who took the bit-reversed form for the canonical one would conclude about I/G and U/L. RFC 2469 records the practical result: bridges between Token Ring and Ethernet had to "perform bit swaps of the addresses in the address fields of ARP packets", the Address Resolution Protocol's (section 3.2).
What it refuses, and why
A field longer than 80 characters; an empty field; hexadecimal without 0x (with a hint), a prefix whose digits do not follow it, octal, a MAC address in value mode (it points to MAC mode); a value of more than 64 bits; a width outside 1 to 64 or a value that does not fit its width (with the bits it needs), and a negative decimal outside the width's two's complement range; an unknown layout, numbering, printed order or MAC form; a layout of another width than the value (with the width to set); a bit number that is not a whole number or does not exist in the width for the chosen numbering (with the range); a last bit without a first; a printed string with anything but 0s, 1s and single separators; and a MAC address that is not six octets in one of the four forms.
Worked examples
- The DNS answer flags 0x81A0 (the Example, from the Learn article on the DNS header): read as the DNS flags, QR, RD, RA and AD are set. QR is MSB 0 bit 0 and LSB 0 bit 15; RD, which IANA numbers bit 7, is LSB 0 bit 8.
- Huawei's PortState 10111100 (the printed-bits Example), least significant bit first: 0x3D, LACP_Activity, Aggregation, Synchronization, Collecting and Distributing set; misread most significant bit first it is 0xBC. The samples 10100000 and 10110000 are 0x05 and 0x0D.
- Cisco's "0111101 (binary)": Cisco's EtherChannel troubleshooting document gives "The expected value for LACP flags is 0x3D (hex) or 0111101 (binary)" (Cisco, document 220367). Typed as
0b0111101, those seven digits are a 7-bit value, and the 8-bit LACP layout refuses it; with the width set to 8 the dropped leading zero comes back and the value is 0x3D, the same octet Huawei prints as 10111100. - RFC 2469's address (the MAC Example): 12-34-56-78-9A-BC is local (U/L 1) and individual, Administratively Assigned under the SLAP, and 48-2C-6A-1E-59-3D bit-reversed; read as canonical, that reversed form would look universal.
- DSCP from ToS 0xB8: MSB 0 bits 0 to 5 are LSB 0 bits 7 to 2,
GENMASK(7, 2), mask 0xFC, shift 2, value 46. - The CRC-32 polynomial 0x04C11DB7 bit-reversed is 0xEDB88320, the kernel's two forms of the same polynomial; RFC 1662's FCS-16 constant 0x8408 reversed is 0x1021.
What it does not do
It reads values and addresses you type; it does not capture traffic or talk to any device. It does not compute checksums or CRCs, convert byte order beyond showing the swapped octets, decode whole headers (the 802.1Q tag decoder, the LACP member link and state reader and the DNS tools do), or name a MAC address's vendor (the OUI lookup does).
Share results
Under the headline, Share results builds a link to this page, only when you press it, that carries the field as typed and the mode's own settings, after the #: input and mode (value, printed or mac) always; in value mode width when typed, layout when one is chosen, and numbering, from and to (when typed) for a field; in printed mode order, layout and the field as in value mode; in MAC mode form. The other modes' settings are not carried.
RFC 3986 (section 3.5, read 2026-11-08) has the fragment "separated from the rest of the URI prior to a dereference", so these values are not sent to the server when the link is opened; they stay in the address bar and the history of whoever opens it, and anyone who has the link can read them.
- How long. A link carries at most 16,384 characters, the bound the site uses for every value after the
#; these fields are far shorter. - Opening a link. The mode and its settings are set as typing would set them, the other modes keep their values, and the page computes. A link with an unknown mode, layout, order, form or numbering, a setting of another mode, a width or bit number that is not one to three digits, a
towithout afrom, a numbering without afrom, or a field over one line or longer than 80 characters is ignored. Accepted or not, the values then leave the page's own address at once, without a request, so a reload, a bookmark or the page's own Share button carries nothing you did not choose to share.
Provenance
The engine is fixed bit arithmetic on BigInt values, with no clock, no network and no randomness. Its golden vectors (set bit-numbering-and-order-golden-2026-11-08) pin all 256 octets in value mode and printed least significant bit first, widths from 1 to 64 (all ones and the top bit alone), width inference from hexadecimal, binary and decimal, negative decimals, every layout on several values, fields in all three numberings including the kernel's own GENMASK_ULL(39, 21) example, printed strings in both orders with separators, MAC addresses in every form and SLAP quadrant, the Examples and samples, the sentences that carry the rules, the API texts and the refusals. Every expected value was computed by a separate Python model written from the documents (bits as text, positions as string indexes, reversal by reversing the text, octets by int.to_bytes), not by running this engine.
API
The same engine answers /api/v1/bit-numbering-and-order on the site's HTTP API; the contract is on the API page, which also says whether this site serves the API.
- Request. A JSON object. Value:
{"mode": "value", "input": "0x81A0", "width": 16, "layout": "dns-flags", "numbering": "msb0", "from": 1, "to": 4};width,layout,numbering,fromandtoare optional. Printed:{"mode": "printed", "input": "10111100", "order": "lsb-first", "layout": "lacp"};order(msb-firstby default) and the rest are optional. MAC:{"mode": "mac", "input": "48-2C-6A-1E-59-3D", "form": "reversed"};form(canonicalby default) is optional. - Response, value and printed.
mode,width,widthInferred,hex,decimal,signed,binary,binaryLsbFirst,octets,bits(eachlsb0,msb0,one,weight,set),setBits(lsb0,msb0,one),ones,parityEven,parityOdd,lowestSet,highestSet,reversed,reversedPerOctet,byteSwapped,wire(lsbFirst,msbFirst),printed(order,typed,otherHex,otherDecimal, or null),layout(id,width,fields,numberingNote, or null),field(numbering,from,to,lsb0Hi,lsb0Lo,msb0From,msb0To,oneHi,oneLo,span,mask,shift,value,valueHex,bits,expression,kernel, or null) andnotes. - Response, MAC.
mode,form,formDefault,canonical,canonicalColon,reversed,firstOctetBits,group,local,broadcast,slap(y,z,quadrant,name, or null),wire,firstBitOnWire,reversedMisread(group,local) andnotes. - Errors. HTTP 400,
invalid_input, with the engine's message, for example"3D" looks hexadecimal: write it with 0x in front (0x3D), so it is not read as decimal..
Sources
- Intel 64 and IA-32 Architectures Software Developer's Manual, volume 1, 253665-084US, June 2024 (read 2026-11-08): 1.3.1, 4.2.1.2, 7.3.7
- IBM z/Architecture Principles of Operation, SA22-7832-13, May 2022 (read 2026-11-08): chapter 3
- RFC 791, Internet Protocol (STD 5, read 2026-11-08): Appendix B
- RFC 1035, Domain Names: Implementation and Specification (STD 13, read 2026-11-08): sections 2.3.2 and 4.1.1; RFC 6895 (BCP 42, read 2026-11-08): section 2; IANA, DNS Header Flags (updated 2026-10-16, read 2026-11-08)
- RFC 3417, Transport Mappings for SNMP (STD 62, read 2026-11-08): section 8
- Huawei, S5700 and S6700 V200R025C00 Command Reference, Link Aggregation Commands (read in a browser on 2026-11-08: the site refuses automated reads): display eth-trunk, Table 5-17
- Cisco, Troubleshoot EtherChannels on Catalyst 9000 Switches, document 220367 (updated 8 August 2024; read in a browser on 2026-11-08: the site refuses automated reads): the expected LACP flags
- IEEE8023-LAG-MIB for IEEE 802.1AX-2020 (read 2026-11-08) and the Linux kernel's include/uapi/linux/if_bonding.h (read 2026-11-08)
- RFC 9542, IANA Considerations and IETF Protocol and Documentation Usage for IEEE 802 Parameters (BCP 141, read 2026-11-08): sections 1.1, 2.1, 2.1.1, 2.1.4 and 2.3.1
- RFC 2469, A Caution On The Canonical Ordering Of Link-Layer Addresses (Informational, read 2026-11-08): sections 2 and 3
- IEEE Registration Authority, Guidelines for Use of EUI, OUI and CID (updated 1 April 2022, read 2026-11-08)
- RFC 1662, PPP in HDLC-like Framing (STD 51, read 2026-11-08): sections 3.1, 4.5.2, 5.5 and appendix C.1
- Texas Instruments, TL16C550D (SLLS597E, read 2026-11-08)
- NXP Semiconductors, UM10204 I2C-bus specification and user manual, Rev. 7.0, 1 October 2021 (read in a browser on 2026-11-08: the site refuses automated reads): 3.1.5 Byte format, Figure 10
- The Linux kernel source, torvalds/linux master (read 2026-11-08): include/linux/spi/spi.h, include/linux/bits.h, include/linux/crc32.h, include/linux/etherdevice.h, include/net/tcp.h and include/linux/if_vlan.h
- IANA, TCP Header Flags (updated 2026-10-22, read 2026-11-08) and RFC 9293, Transmission Control Protocol (STD 7, read 2026-11-08): section 3.1
- RFC 2474, the DS Field (read 2026-11-08): section 3; RFC 3168, ECN (read 2026-11-08): section 5
- RFC 3986, Uniform Resource Identifier (URI): Generic Syntax (STD 66, read 2026-11-08): section 3.5
- RFC Editor, RFC index (read 2026-11-08): the status of every RFC above