Binary / Decimal / Hex Converter
Convert between binary, decimal, hexadecimal, and octal. Live bidirectional conversion with signed/unsigned views, bit grouping, and ASCII preview.
How to Use
- Type a value in any base — all fields update live.
- Prefixes work: 0x for hex, 0b for binary, 0o or 0 for octal.
- Pick signed or unsigned display for negative numbers.
- Bit width controls the signed range (8, 16, 32, 64 bit).
Details
Formulas
History of Number Bases in Computing
Gottfried Wilhelm Leibniz formally described binary arithmetic in 1703, but its connection to digital electronics came much later. Claude Shannon\'s 1938 master\'s thesis at MIT — "A Symbolic Analysis of Relay and Switching Circuits" — showed that Boolean algebra and binary numbers could describe any digital circuit. This work, performed when Shannon was 21, essentially founded digital design as a mathematical discipline.
Octal (base 8) dominated early computing because many mainframes had word widths that were multiples of 3 bits: the PDP-1 (18-bit), PDP-10 (36-bit), and various IBM machines used octal for easy word-level representation. Unix inherited the convention (its "chmod 755" file-permission syntax is octal), but octal largely died with 16/32/64-bit architectures whose byte boundaries don\'t align with 3-bit groupings.
Hexadecimal (base 16) replaced octal as the standard engineering notation when 8-bit bytes became universal in the 1970s. Each hex digit maps to exactly 4 bits (half a byte, i.e. a nibble), so a byte is always 2 hex characters — visually clean and free of byte-boundary confusion. The C programming language\'s 0x prefix (1972) became the de-facto standard across most subsequent languages. Today, memory addresses, register values, and binary blobs are almost universally displayed in hex.
About This Calculator
Type a value in any base — decimal, hex, binary, or octal — and all the other fields update live. Prefixes are respected (0x, 0b, 0o) and stripped for conversion. Pick a bit width (8, 16, 32, or 64) to constrain the signed/unsigned range; pick signed or unsigned to change how negative values are displayed.
Also shown: two\'s complement interpretation, bit-count (popcnt — useful for debugging bitmap operations), and ASCII character if the value falls in printable range. Useful for register decoding, packed-data debugging, color-code conversion, and general bit-level analysis. All math runs client-side.
Frequently Asked Questions
Why are hex and binary common in electronics?
Microcontrollers, memory layouts, and data sheets use binary (bit-level operations), hex (compact 4-bit groupings), and octal (3-bit groupings, historical Unix permissions). Decimal is for humans; hex is for engineers.
What is two's complement?
The standard way to represent negative integers in binary. Flip all bits and add 1. In 8-bit signed: -1 = 0xFF, -128 = 0x80. The MSB acts as a sign bit. Standard in nearly all modern CPUs.
What's the signed range of N bits?
Unsigned: 0 to 2^N − 1. Signed (two\'s complement): −2^(N−1) to 2^(N−1) − 1. For 8-bit: unsigned 0–255; signed −128 to +127.
What does the 0x prefix mean?
0x is the standard prefix for hexadecimal. 0b for binary, 0o (or leading 0) for octal. These are C-style conventions used by most languages. Without a prefix, the tool guesses — try with prefix if the value has ambiguous characters.
Common Use Cases
Register Decoding
MCU datasheet shows GPIO_MODER = 0x55555555. Decode into 16 × 2-bit mode fields to see which pins are inputs/outputs.
Bit-Level Debugging
Check that bit 7 of a status byte is set: binary view makes it obvious; hex doesn't.
Packed Data Format
MIDI messages, UART frames, network protocols — all pack meaning into bit fields. Convert to binary to inspect.
Color Codes
RGB #FF8800 = 255, 136, 0 decimal. Quickly convert hex color to individual RGB channel values.
Unix File Permissions
chmod 755 = 111 101 101 binary = rwx r-x r-x. Octal maps directly to 3-bit permission groups.
Last updated: