Menu

Number Base Converter

Purpose: Convert a value between binary, octal, decimal and hexadecimal - type in any field and the rest update live.

Number Base Converter: How It Works

Every number system works the same way — each position is worth a power of the base. Understanding that one idea makes binary, octal and hexadecimal straightforward, and explains why programmers reach for hex constantly while ordinary arithmetic never needs it.

Positional value

In base 10, 3,742 means 3×10³ + 7×10² + 4×10¹ + 2×10⁰. Every base follows the identical pattern with a different multiplier.

BaseNameDigitsWhere used
2Binary0–1All digital hardware; bit flags
8Octal0–7Unix file permissions
10Decimal0–9Everyday arithmetic
16Hexadecimal0–9, A–FColours, memory addresses, hashes

Converting by hand

To decimal: multiply each digit by its positional value and sum. Binary 1101 = 8 + 4 + 0 + 1 = 13. Hex 2F = 2×16 + 15 = 47.

From decimal: divide repeatedly by the base and read the remainders bottom to top. For 156 to binary: 156÷2=78 r0, 78÷2=39 r0, 39÷2=19 r1, 19÷2=9 r1, 9÷2=4 r1, 4÷2=2 r0, 2÷2=1 r0, 1÷2=0 r1 → 10011100.

Why hex and not something else

Sixteen is 2⁴, so exactly four binary digits map to one hex digit — with no arithmetic at all.

BinaryHexBinaryHex
0000010008
0001110019
001021010A
001131011B
010041100C
010151101D
011061110E
011171111F

A byte is eight bits, so exactly two hex digits: 11111111 is FF is 255. This is why colours are written #RRGGBB — six hex digits, two per channel, each ranging 00 to FF.

Octal works the same way with three bits per digit, which is why Unix permissions are octal: 755 is 111 101 101, and each group is read/write/execute for owner, group and others.

Notation prefixes

PrefixBaseExample
0bBinary0b1101
0o or leading 0Octal0o755
0xHexadecimal0x2F
#Hex colour#3B82F6

A leading zero meaning octal is a genuine hazard in older C-family languages: 010 is 8, not 10. Several bugs in date and time handling have come from parsing '08' and '09' as octal, where those digits are not even valid.

Bases beyond 16

Base 32 and base 36 use letters beyond F and appear in short URL identifiers and licence keys. Base 58 — used in cryptocurrency addresses — deliberately omits 0, O, I and l because they are easily confused when read or transcribed by a human, which is a nice example of a design choice made for people rather than machines.

Frequently Asked Questions

Why do computers use binary?
Because electronic components reliably distinguish two states — on and off, high and low voltage — but not ten. Two states give the largest noise margin and the simplest, most reliable circuitry.
Why is hexadecimal used instead of binary?
Because 16 is 2⁴, so one hex digit maps to exactly four bits with no calculation. A byte becomes two hex characters instead of eight binary ones — far shorter to write and much easier to read without losing the bit structure.
Why are Unix permissions written in octal?
Because 8 is 2³, so each octal digit represents exactly three bits — read, write and execute. 755 is 111 101 101, which is full permissions for the owner and read-execute for group and others.
What does 0x mean before a number?
It marks the value as hexadecimal. Similarly 0b marks binary and 0o marks octal. A bare leading zero means octal in older C-family languages, which is a real source of bugs.
How do I convert decimal to binary by hand?
Divide repeatedly by 2, recording each remainder, then read the remainders from the last division backwards. The same method works for any base — divide by that base instead.
Why do hex colours use six digits?
Two hex digits per colour channel — red, green, blue — each covering 00 to FF, which is 0 to 255. That gives 256 levels per channel and about 16.7 million colours in total.

Related Calculators Tools

Browse all Calculators tools →