ScienForge

Binary, hex and decimal converter

Convert a whole number between binary, octal, decimal, hexadecimal and any base from 2 to 36, with bit width shown.

Decimal
255
Binary11111111
Hexadecimal0xFF
Octal0o377
Base 3673
Bits needed8
Fits in8 bits
Padded byte form11111111

A number base is just how many digits you count with before rolling over. Decimal uses ten, binary uses two, hexadecimal uses sixteen. The quantity being represented never changes — only the notation does.

value = Σ digitᵢ × baseⁱ

So 1011 in binary is 1×8 + 0×4 + 1×2 + 1×1 = 11, and FF in hex is 15×16 + 15 = 255.

Why hexadecimal exists

Sixteen is a power of two, so each hex digit maps to exactly four bits with no arithmetic required. A byte is always exactly two hex digits, which makes memory dumps, colour codes and register values far easier to read than the equivalent binary. Octal survives for the same reason in Unix file permissions, where three bits per digit matches the read-write-execute grouping.

Prefixes

Most languages mark the base with a prefix: 0b for binary, 0o for octal, 0x for hex. A leading zero alone means octal in C and several languages derived from it, which is a long-standing source of bugs — 010 is eight, not ten.

Bit width matters in embedded work

An 8-bit register holds 0 to 255 unsigned, or −128 to 127 signed using two’s complement. Writing 256 into it wraps to zero. This calculator shows how many bits a value needs, which is the check to do before choosing a variable type.