Number Bases Guide

Why Different Bases?

Computers store everything as binary (base 2) — switches that are either on (1) or off (0). Decimal (base 10) is what humans use daily. Hexadecimal (base 16) is used in programming because each hex digit represents exactly 4 binary bits, making it a compact representation of binary data. The hex digits are 0–9 and A–F (A=10, B=11, C=12, D=13, E=14, F=15). Octal (base 8) was common in older computing systems and some Unix file permission notations.

What do I need to know about Decimal to Binary Conversion?

Method: divide the decimal number by 2 repeatedly, noting the remainder each time. Read remainders from bottom to top. Example: 13 in binary: 13÷2=6 r1, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1 → read up: 1101. Check: 1×8 + 1×4 + 0×2 + 1×1 = 8+4+0+1 = 13 ✓. Decimal to hex: divide by 16 repeatedly. Decimal to octal: divide by 8 repeatedly.

What's the key thing to understand about Common Hex Values?

In programming and web design, hex values appear constantly: 0xFF = 255 (maximum single byte), 0x00 = 0 (minimum), 0x0F = 15 (lower nibble), 0xF0 = 240 (upper nibble), 0x7F = 127 (largest positive signed byte), 0x80 = 128, 0x1000 = 4096, 0xFFFF = 65535. Web colours: #FF0000 = pure red, #00FF00 = pure green, #0000FF = pure blue, #FFFFFF = white, #000000 = black. RGB values 0–255 convert directly to 00–FF in hex.

What's the key thing to understand about Binary Arithmetic?

Adding binary: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry 1). Example: 0110 (6) + 0011 (3) = 1001 (9). Bitwise operations: AND (both 1), OR (either 1), XOR (different), NOT (flip). These operations are fundamental in computer processors, cryptography, and network subnetting. IP addresses are 32-bit binary numbers divided into 4 groups of 8 bits (octets). 192.168.1.1 in binary: 11000000.10101000.00000001.00000001.

What should I know about Octal (Base 8)?

Octal uses eight digits (0–7) and was historically popular in early computing because, like hexadecimal, it divides evenly into binary: each octal digit corresponds to exactly 3 binary bits (since 2³ = 8), making conversion between binary and octal a simple matter of grouping bits in sets of three from the right. For example, binary 101110 splits into 101 and 110, giving octal 56. Octal remains in everyday use today in Unix and Linux file permission notation — a command like chmod 755 sets read/write/execute permissions using three octal digits, one each for owner, group, and others, where each digit (0–7) encodes a combination of read (4), write (2), and execute (1) permissions. Outside of this niche, octal has largely been superseded by hexadecimal for representing binary data, since hex more conveniently groups bits in sets of four (matching the common 8-, 16-, 32-, and 64-bit word sizes used in modern computing) and so requires fewer digits to represent the same value.

What's the key thing to understand about Converting Between Two Non-Decimal Bases?

To convert a number directly between two bases that are neither of them base 10 — say, octal to hexadecimal — the simplest reliable method is to use decimal as an intermediate step: convert the original number to decimal first, then convert that decimal value into the target base. There is one useful shortcut: when both bases are powers of the same number (binary, base 2; octal, base 8 = 2³; and hexadecimal, base 16 = 2⁴ are all powers of 2), you can convert via binary by grouping bits, without ever calculating a decimal value. For example, to convert octal 17 to hexadecimal: first expand each octal digit to 3 bits (1 = 001, 7 = 111), giving binary 001111, then regroup into 4-bit chunks from the right (0011 1111 — pad the leftmost group with zeros as needed) to get hex F. This bit-grouping trick is faster and less error-prone than going through decimal, but it only works because 2, 8, and 16 share the same base-2 root — converting, say, base 7 to base 9 genuinely requires the decimal intermediate step.

What do I need to know about Fractional Numbers in Different Bases?

Just as whole numbers can be represented in any base, so can fractional (non-integer) values — each digit after the "point" represents a negative power of the base instead of a positive one. In binary, the digits after the binary point represent 1/2, 1/4, 1/8, 1/16, and so on, so 0.101 in binary equals 1×(1/2) + 0×(1/4) + 1×(1/8) = 0.625 in decimal. Not every decimal fraction converts to a finite binary fraction — 0.1 in decimal is actually an infinitely repeating binary fraction (0.0001100110011...), which is the root cause of the famous floating-point rounding quirks programmers encounter, like 0.1 + 0.2 not displaying as exactly 0.3 in many programming languages. Converting a decimal fraction to another base is done by repeatedly multiplying the fractional part by the target base and recording the integer part that falls out each time.

Worked Example: Converting 213 to Binary, Octal, and Hexadecimal

The cleanest way to convert a decimal number into another base by hand is repeated division: divide by the target base, write down the remainder, then keep dividing the quotient until it reaches zero. Reading the remainders from last to first gives the converted number. Take 213 in decimal. For binary (base 2): 213÷2=106 r1, 106÷2=53 r0, 53÷2=26 r1, 26÷2=13 r0, 13÷2=6 r1, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1. Reading the remainders bottom-to-top gives 11010101. Checking it: 128+64+16+4+1 = 213, which confirms the conversion. For octal (base 8): 213÷8=26 r5, 26÷8=3 r2, 3÷8=0 r3. Reading bottom-to-top gives 325 (octal). Check: 3×64 + 2×8 + 5×1 = 192+16+5 = 213. For hexadecimal (base 16): 213÷16=13 r5, 13÷16=0 r13. Since 13 is 'D' in hex notation, the result is D5. Check: 13×16 + 5 = 208+5 = 213.

Target BaseDivision Steps (quotient → remainder)Result
Binary (2)213→106 r1→53 r0→26 r1→13 r0→6 r1→3 r0→1 r1→0 r111010101
Octal (8)213→26 r5→3 r2→0 r3325
Hexadecimal (16)213→13 r5→0 r13 (D)D5

This division-remainder method works for any base and is exactly what a base converter automates, but doing one example by hand makes it much easier to spot an input or calculator error.

Two's Complement and Representing Negative Numbers in Binary

Plain binary only represents non-negative integers, so computers use a scheme called two's complement to store negative numbers using the same bit patterns. To find the two's complement of a number, write the positive value in binary, flip every bit (0 becomes 1, 1 becomes 0), then add 1 to the result. In an 8-bit system, +5 is 00000101. Flipping gives 11111010, and adding 1 gives 11111011, which represents −5. The most significant (leftmost) bit acts as a sign flag in this scheme: 0 means positive, 1 means negative, which is why an 8-bit two's complement byte ranges from −128 to +127 rather than 0 to 255. This asymmetry (one more negative value than positive) is a common source of off-by-one bugs in low-level code.

Decimal Value4-Bit Two's Complement Binary
70111
30011
00000
-11111
-31101
-81000

Understanding two's complement also explains a quirk some users notice when converting negative numbers: the binary pattern alone does not tell you whether it is 'unsigned' or a negative 'signed' value without knowing which convention is in use.

Why Computing Uses Binary (and Hex) Instead of Decimal

Digital electronics store information as two physical states — typically a high voltage and a low voltage — which maps naturally onto binary's two digits, 0 and 1, rather than the ten digits decimal would require. Hexadecimal is popular as a human-friendly shorthand for binary specifically because each hex digit corresponds exactly to 4 binary bits (a 'nibble'), so a long binary string like 11010101 can be written far more compactly as D5, with no rounding or approximation involved in the conversion, unlike converting between decimal and binary, which does not line up so neatly.

Quick Reference: Decimal 0-16 in Binary, Octal and Hex

A small lookup table for the values used constantly in computing and electronics.

DecimalBinaryOctalHexadecimal
0000000
4010044
81000108
10101012A
15111117F
16100002010

Memorising even the first sixteen hex values (0-F) is enough to read most colour codes, memory addresses and permission flags at a glance, since every hex digit maps to exactly one group of four binary bits — a pattern that doesn't hold for decimal, which is the main reason programmers default to hex rather than base 10 when working close to the hardware.

Number Base Converter (Binary, Hex, Octal)

Results update automatically as you type

Enter values above to calculate