01 / From machine bits to readable notation
Positional notation predates electronic computers. Leibniz published a systematic account of binary arithmetic in 1703. In the twentieth century, digital circuits gave two-state representation a practical advantage: logic devices can distinguish stable states rather than measure continuous amplitudes precisely. Binary is useful to machines, not particularly readable to people.
Octal and hexadecimal make bits easier to inspect: an octal digit represents three bits, a hex digit four. Octal suited early 12-, 18- and 36-bit machines. As eight-bit bytes became common, two hex digits conveniently represented one byte. Systems such as IBM System/360 helped establish the eight-bit byte, but other byte widths have existed.
Hex changes readability, not information content. The 0x prefix is notation, not an extra byte in memory; A–F are digits here. Leading zeros usually do not change an integer's value, but field width and leading zeros can carry structure in protocols, coordinates and byte buffers.
02 / Two's complement and shared arithmetic hardware
Sign-and-magnitude notation is intuitive, but arithmetic must handle combinations of signs and magnitudes. One's complement also has positive and negative zero and end-around carry. Two's complement represents negatives modulo 2ⁿ, letting one n-bit adder perform addition and subtraction. Subtracting x becomes adding its complement, with carry beyond the width discarded.
In eight bits, −1 is represented by 256−1=255, or 11111111. Adding one produces 1 00000000; retaining eight bits leaves zero. This carry rule belongs to fixed-width arithmetic, not the mathematical statement that 255+1 equals zero. The pattern 11111111 can mean unsigned 255 or signed −1. Signedness comes from the type or protocol, not the bits alone.
The signed range is −2ⁿ⁻¹ to 2ⁿ⁻¹−1, with one more negative value than positive. The smallest negative value's magnitude cannot fit in the same signed width. Widen negative values with sign extension: zero-extending the eight-bit pattern for −1 to 0000000011111111 produces 255, not −1.
03 / Byte order and interoperability
A multi-byte integer needs a rule for which byte comes first. Big-endian puts the most significant byte first; little-endian puts the least significant first. Architecture choices reflect history, implementation and memory access. Little-endian makes low-order parts accessible at low addresses; big-endian matches how numbers are written. Neither is best for every operation.
Danny Cohen used the endian metaphor in his 1980 paper On Holy Wars and a Plea for Peace. Many Internet protocols use big-endian network byte order, but a format may specify little-endian, mixed fields or per-field encoding. Common x86 memory layouts do not determine packet layouts.
For the 32-bit value 0x12345678, big-endian bytes are 12 34 56 78 and little-endian bytes are 78 56 34 12. What changes is byte order, not the bits inside each byte or the individual hex characters. Byte order is a storage and transmission convention; it does not change the mathematical value.
Mathematical integers are unbounded; machine fields are not
An n-bit word has patterns from 0 to 2ⁿ−1. Signed interpretation gives the top bit a weight of −2ⁿ⁻¹. Out-of-range behavior must be specified: rejection, checked overflow, saturation and modular wraparound are different choices. Unsigned modular arithmetic is also not the same as signed language rules; C signed overflow cannot be treated as guaranteed hardware wraparound.
JavaScript Number uses IEEE 754 binary64. Its continuous safe integer range ends at ±(2⁵³−1). Converting 9007199254740993 to Number can lose precision before any base conversion. This page parses with an arbitrary-precision integer library and uses BigInt for bit patterns. Exported JSON stores values as strings to avoid another loss of precision.
Only integers are accepted, with up to 4096 input characters and byte-aligned widths from 8 to 4096 bits. Out-of-range values retain their exact base conversion but are not truncated into misleading bytes. Negative values keep their minus sign; two's complement is shown separately. Floating-point values, fractions and memory dumps are not parsed. Input stays on this page and is not saved automatically.