Convert between binary, octal, decimal and hex.
Decimal value = Σ (dᵢ × Bⁱ) for i = 0 to n−1 where the digits are read right-to-left (position 0 is the rightmost digit). Decimal → Base B: repeatedly divide N by B; remainders (read bottom-to-top) give the result.
Every positional numeral system assigns a place value that is a power of the base. To convert a number from base B to decimal (base 10), multiply each digit by B raised to the power of its position (counting from 0 at the rightmost digit) and sum the results. To convert from decimal to base B, repeatedly divide the decimal value by B and collect the remainders in reverse order. For hexadecimal, digits above 9 are represented as A=10, B=11, C=12, D=13, E=14, F=15.
**Decimal → Binary (base 2):** 255 ÷ 2 = 127 remainder 1 127 ÷ 2 = 63 remainder 1 63 ÷ 2 = 31 remainder 1 31 ÷ 2 = 15 remainder 1 15 ÷ 2 = 7 remainder 1 7 ÷ 2 = 3 remainder 1 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 Read remainders bottom-to-top → 11111111 **Decimal → Octal (base 8):** 255 ÷ 8 = 31 remainder 7 31 ÷ 8 = 3 remainder 7 3 ÷ 8 = 0 remainder 3 Read remainders bottom-to-top → 377 **Decimal → Hexadecimal (base 16):** 255 ÷ 16 = 15 remainder 15 → F 15 ÷ 16 = 0 remainder 15 → F Read remainders bottom-to-top → FF
Result: 255 (decimal) = 11111111 (binary) = 377 (octal) = FF (hexadecimal)
The decimal value 255 is a classic example in computing — it equals 2⁸ − 1, meaning all 8 bits in one byte are set to 1, shown clearly by the binary result 11111111. In octal, 377 is frequently used in Unix file permissions. The hexadecimal FF is ubiquitous in web color codes (#FFFFFF = white) and memory address masks. All four representations refer to exactly the same quantity — they simply use different positional bases to express it.
A numeral base (or radix) defines how many unique digits a positional number system uses before it 'carries over' to the next place. Humans naturally use base 10 (decimal) — ten digits, 0–9. Computers operate on base 2 (binary) — only two states, 0 and 1, matching off/on electrical signals.
| Base | Name | Digits Used | Common Use | |------|-------------|--------------------------|-----------------------------| | 2 | Binary | 0, 1 | CPU logic, bitwise ops | | 8 | Octal | 0–7 | Unix permissions, legacy | | 10 | Decimal | 0–9 | Everyday arithmetic | | 16 | Hexadecimal | 0–9, A–F | Colors, memory addresses |
One hexadecimal digit represents exactly 4 binary bits (a nibble). Two hex digits represent a full byte (8 bits), making hex a compact and human-readable shorthand for binary data — which is why memory dumps, color codes, and MAC addresses all use it.
Octal encodes 3 binary bits per digit. Unix file permissions are stored as 9 bits (read/write/execute for owner, group, world), so three octal digits perfectly capture them: chmod 755 means 111 101 101 in binary.
Every digit in a positional number has a weight equal to the base raised to that digit's position index. For example, binary 1011 = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 in decimal.
1024 in decimal equals 400 in hexadecimal. Calculation: 1024 ÷ 16 = 64 remainder 0; 64 ÷ 16 = 4 remainder 0; 4 ÷ 16 = 0 remainder 4. Reading remainders bottom-to-top: 400.
Web colors are expressed as six hex digits (#RRGGBB), where each pair represents a byte (0–255) for red, green, and blue intensity. For example, #FF5733 has red=255, green=87, blue=51.
Unix permissions are three groups of three bits (read=4, write=2, execute=1). Each group is summed to a single octal digit, giving codes like 755 (owner: rwx=7, group: r-x=5, others: r-x=5).
Two's complement is the standard way to represent signed (positive and negative) integers in binary. To negate a number, invert all bits and add 1. It simplifies CPU addition circuits because positive and negative numbers can be added with the same hardware.
Each octal digit maps to exactly 3 binary bits. Replace every octal digit with its 3-bit binary equivalent. For example, octal 57 = 5→101, 7→111, so the binary result is 101111.
They are all positional numeral systems that express the same quantities using different bases: binary uses base 2 (digits 0–1), octal uses base 8 (digits 0–7), decimal uses base 10 (digits 0–9), and hexadecimal uses base 16 (digits 0–9 and A–F). The underlying value is identical — only the notation differs.
Write down the binary number, then multiply each digit by 2 raised to its position (starting at 0 from the right) and sum all the products. For example, 1101 = 1×8 + 1×4 + 0×2 + 1×1 = 13 in decimal.
'0x' is a prefix used in programming languages like C, Python, and JavaScript to indicate that the following number is in hexadecimal (base 16). For example, 0xFF means FF in hex, which equals 255 in decimal.
Electronic circuits are most reliably built with two states — voltage present (1) or absent (0). Binary maps perfectly onto these two states, making it the natural language of digital hardware.
This calculator is designed for non-negative integers. Negative numbers in binary use representations like two's complement, and fractional bases require radix-point arithmetic — these are advanced topics beyond standard base conversion for whole numbers.
Exactly two hexadecimal digits represent one byte (8 bits), since each hex digit encodes 4 bits (log₂16 = 4). That's why byte values range from 00 to FF in hex (0 to 255 in decimal).
Only sources that have been reviewed are shown. Unverified citations are never published.