Kulkalotar
Math & Conversion

Binary, Hex, Decimal Converter

Convert between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Essential for programming, networking, and computer science.

Binary
11111111
Octal
377
Decimal
255
Hex
FF

What this calculates

Computers use binary natively, programmers commonly read hex, and decimal is for humans. This converter handles base 2, 8, 10, and 16 in any direction. Essential for low-level programming, embedded development, color codes (which are hex), and understanding bitwise operations.

Formula & how it works

Decimal to base b: repeatedly divide by b, the remainders read in reverse give the digits. Base b to decimal: each digit × b^(position), sum from right (position 0). Hex digits: 0-9 then A-F (10-15). Binary is naturally compact: 8 bits = 1 byte = 0-255. Hex pairs to bytes: 0xFF = 255.

Worked example

255 in different bases: decimal 255, hex FF, binary 11111111, octal 377. The hex form (FF) takes 2 digits, binary takes 8 — that's why programmers prefer hex for readability when bytes are involved. Computer colors are hex: #FF0000 = (255, 0, 0) red.

Frequently asked questions

Why hex for memory and colors?

Hex is base-16, which maps cleanly to 4-bit nibbles. Two hex digits = 1 byte exactly. Memory addresses and RGB colors are byte-based, so hex avoids the eyestrain of binary.

What's two's complement?

Way to represent negative integers in binary. The most significant bit is the sign. 8-bit two's complement range: -128 to +127. JavaScript number type handles this transparently for bitwise ops.

Why octal?

Historical — 1960s/70s computers had word sizes (12, 24, 36 bits) that divided cleanly by 3 (octal digits are 3 bits each). Today only Unix file permissions (chmod 755) and a few legacy contexts still use it.

Largest safe integer?

JavaScript: 2^53 - 1 (about 9 × 10^15). Beyond that, BigInt is required. Most everyday conversions are well within range.

Last updated:

Related calculators