Hex Calculator Explained: How Number Bases Actually Work

Hexadecimal, binary, and octal are not a separate kind of maths — they are ordinary counting written with a different number of symbols. This guide explains what a number base is, how conversion works in both directions, and why hex is the shorthand programmers reach for, with a worked example that ties all four bases together.

#hexadecimal#binary#octal#decimal#base conversion#number systems

Hexadecimal looks like a secret language the first time you meet it — a memory dump full of things like 0x1A3F, a colour written as #FF8800, a permission set to 755. None of it is arbitrary. Every one of those is the same kind of ordinary counting you already do in decimal, just written with a different number of symbols. The hex calculator converts a value between hexadecimal, decimal, binary, and octal instantly, and this guide explains what is actually happening underneath so the output stops looking like magic.

What a number base actually is

A number is a count. “How many” does not change when you write it differently — a dozen eggs is a dozen eggs whether you call it 12, C, or 1100. A base (or radix) is simply how many distinct symbols you use before you run out and have to start a new column. Decimal is base 10: it uses ten symbols, 0 through 9, then rolls over to 10. That is the whole idea, and it generalises directly.

  • Decimal (base 10) uses 0–9 — ten symbols. The system almost everyone counts in.
  • Hexadecimal (base 16) uses 0–9 and then A, B, C, D, E, F for the values ten through fifteen — sixteen symbols in total.
  • Binary (base 2) uses only 0 and 1 — two symbols. This is how computers physically store data: each binary digit, or bit, is one on/off switch.
  • Octal (base 8) uses 0–7 — eight symbols. Less common today, but it survives in a few corners of computing.

The letters in hex trip people up, but there is nothing special about them. Base 16 needs sixteen symbols and the decimal digits only supply ten, so the first six letters of the alphabet get drafted in as digits: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. Once you accept that F is just a one-symbol way of writing “fifteen”, hexadecimal stops being intimidating.

How base conversion works

Every positional number system assigns a value to each column based on a power of the base. In decimal the columns are ones, tens, hundreds, thousands — that is 10⁰, 10¹, 10², 10³. In hexadecimal the columns are 16⁰, 16¹, 16² — ones, sixteens, two-hundred-and- fifty-sixes. To turn any number into its decimal value you multiply each digit by its column weight and add:

value = dₙ · baseⁿ + … + d₂ · base² + d₁ · base¹ + d₀ · base⁰

Reading a hex number into decimal is exactly this. Take 2F: the 2 sits in the sixteens column and the F (fifteen) sits in the ones column, so 2F = (2 × 16) + (15 × 1) = 32 + 15 = 47. Going the other way — decimal into another base — you repeatedly divide by the base and collect the remainders from bottom to top. Divide by 16 for hex, by 8 for octal, by 2 for binary. The number base converter runs both directions for you, but knowing the two algorithms means you can check any result on paper.

Worked example

Take the decimal number 700 and convert it to all four bases. Type 700 into the hex calculator with the input base set to decimal to follow along.

Decimal to hexadecimal — divide by 16:

700 ÷ 16 = 43 remainder 12  (12 = C) 43 ÷ 16 =  2 remainder 11  (11 = B) 2 ÷ 16 =  0 remainder  2  ( 2 = 2)

Reading the remainders from the bottom up gives 2BC. Check it forwards: (2 × 256) + (11 × 16) + (12 × 1) = 512 + 176 + 12 = 700. Correct.

The same value in the other bases:

  • Hexadecimal: 0x2BC
  • Binary: 0b1010111100 (ten bits)
  • Octal: 0o1274

Here is the detail that makes hex so useful to programmers. Group the binary from the right in blocks of four and pad the front with zeros: 0010 1011 1100. Now read each block as a single hex digit — 0010 = 2, 1011 = B, 1100 = C — and you get 2BC straight off, no arithmetic required. Four bits always collapse into exactly one hex digit, which is why hex is the natural shorthand for binary data.

The 0x, 0b, and 0o prefixes

A bare 101 is ambiguous: it could be one-hundred-and-one in decimal, five in binary, or two-hundred- and-fifty-seven in hex. To remove the doubt, most programming languages tag literals with a prefix. 0x means the digits that follow are hexadecimal (0xFF = 255), 0b means binary (0b11111111 = 255), and 0o means octal (0o377 = 255). All three of those examples are the same number written three ways. The hex calculator accepts and prints these prefixes so you can paste a value straight from source code without stripping it first.

Where each base shows up in real work

Bytes, nibbles, and the number 255

A byte is eight bits, and eight bits can represent 256 distinct values, 0 through 255. In binary the maximum is 11111111; in hex it is FF. That is not a coincidence — two hex digits cover exactly one byte, because each hex digit is four bits (a nibble) and two nibbles make a byte. This is why byte values, memory contents, and file formats are almost always shown in hex: a screen full of two-digit hex pairs is far easier to scan than the same data as eight-digit binary strings.

Colour codes

A web colour like #FF8800 is three bytes: red, green, and blue, each a value from 0 to 255 written as two hex digits. Here red is FF (255, full intensity), green is 88 (136, a little over half), and blue is 00 (none) — an orange. White is #FFFFFF (all channels maxed) and black is #000000. If you want to blend two of these rather than just read them, the colour mixer does the sRGB maths and hands back the resulting hex.

File permissions

Unix and Linux permissions are where octal still earns its keep. A command like chmod 755 uses three octal digits, one each for owner, group, and everyone else. Each digit is a sum of read (4), write (2), and execute (1): 7 = 4+2+1 = rwx, 5 = 4+0+1 = r-x. Octal fits because the three permission bits map perfectly onto a single 0–7 digit.

Addresses and identifiers

Hardware and network addressing leans on hex heavily. A MAC address is six bytes shown as twelve hex digits. IPv6 addresses are written in hex groups, unlike the dotted-decimal IPv4 you may know from the IP subnet calculator. Memory addresses in a debugger, error codes, and hash digests all arrive in hex for the same reason: it is the most compact human-readable form of raw binary.

Converting by hand, quickly

You will not always have a converter open, so a few shortcuts are worth carrying in your head.

  • Hex to binary: expand each hex digit into its four-bit pattern and concatenate. A = 1010, 3 = 0011, so A3 = 10100011. No division needed.
  • Binary to hex: group the bits in fours from the right, pad the leftmost group with zeros, and read each group as a hex digit.
  • Hex to decimal: for two digits, multiply the first by 16 and add the second. 3C = (3 × 16) + 12 = 60.
  • Decimal to hex: divide by 16, note the remainder as the last digit, repeat on the quotient, and read the remainders bottom to top.
  • Memorise the anchors: F = 15, FF = 255, FFF = 4095, FFFF = 65535. Each extra F multiplies the ceiling by sixteen and adds one.

For arithmetic within binary or hex — adding two hex numbers, running a bitwise AND — the binary calculator handles the operations and shows the result in binary, decimal, and hex at once.

Common mistakes

Reading hex digits as decimal

The single most common slip is treating 10 in hex as “ten”. In hexadecimal 10 means sixteen (one sixteen, zero ones), and 20 means thirty-two. The value ten is written A. Whenever a number could plausibly be more than one base, look for the prefix or the surrounding context before assuming it is decimal.

Forgetting to pad when grouping binary

Binary-to-hex grouping works from the right, and the leftmost group must be padded to four bits. The binary 1010111100 is ten bits; splitting it naively from the left gives the wrong nibbles. Pad it to 0010 1011 1100 first, and only then read off 2BC.

Assuming hex handles negatives or decimals the same way

Plain positional hex, like the hex calculator uses, represents non-negative whole numbers. Negative values in computing are stored with a scheme called two’s complement, where 0xFF means −1 in a signed 8-bit context but 255 unsigned — the bits are identical, only the interpretation differs. Fractional values use yet another format (floating point). This tool is for integer base conversion, not signed or fractional encoding.

Confusing octal with a leading zero

In some older languages a literal like 0755 was read as octal purely because of the leading zero, which quietly turned “seven hundred and fifty-five” into 493. Modern languages use the explicit 0o prefix to avoid the trap, but the historical behaviour still bites people copying old code.

When the calculator is not enough

The hex calculator converts a single non-negative integer between the four common bases. A few tasks sit outside that scope:

  • Signed integers: to see how a negative number is stored, you need two’s-complement encoding for a fixed bit width (8, 16, 32, or 64 bits), which depends on the width you choose.
  • Very large integers: values beyond the safe integer range that JavaScript can represent exactly (roughly 9 quadrillion) need arbitrary-precision (BigInt) handling to convert without rounding.
  • Fractions: hexadecimal can represent fractional parts (digits after a radix point), and floating- point numbers have their own hex representation, but that is a separate calculation from whole-number conversion.
  • Arithmetic across bases: to add, subtract, or apply bitwise logic rather than just convert, reach for the binary calculator or an exponent calculator for the powers-of-two that underlie the column weights.

Frequently asked questions

What is hexadecimal in simple terms? It is a way of writing numbers using sixteen symbols instead of ten: the digits 0–9 plus the letters A–F for the values ten through fifteen. It represents exactly the same quantities as decimal — just more compactly for computer data, because one hex digit stands in for four binary bits.

How do I convert hex to decimal by hand? Multiply each hex digit by 16 raised to its position (counting from 0 on the right) and add the results. For 2F: (2 × 16¹) + (15 × 16⁰) = 32 + 15 = 47. Substitute A=10 through F=15 for the letter digits before multiplying.

Why do programmers use hexadecimal? Because it is a clean shorthand for binary. Every four bits map to exactly one hex digit and every byte to exactly two, so a block of raw data that would be an unreadable wall of 0s and 1s in binary becomes a short, scannable string in hex. Memory addresses, byte values, colours, and hashes are all shown in hex for this reason.

What does the 0x prefix mean? It signals that the following digits are hexadecimal. 0xFF is the hex number FF, which equals decimal 255. The related prefixes are 0b for binary and 0o for octal. The calculator accepts and displays all three.

What is the largest number in one byte, and why is it 255? A byte is eight bits, and eight bits give 2⁸ = 256 combinations, running from 0 to 255. In hex that maximum is FF and in binary 11111111. Add one more and it rolls over to 256 (0x100), which needs a ninth bit.

What is the difference between a bit, a nibble, and a byte? A bit is a single binary digit (0 or 1). A nibble is four bits and maps to exactly one hex digit (0–F). A byte is eight bits — two nibbles — and maps to two hex digits (00–FF), holding values 0 to 255.

Is octal still used for anything? Mainly Unix and Linux file permissions, where a command such as chmod 644 uses three octal digits to set read, write, and execute bits for owner, group, and others. Outside that, hex has largely replaced octal in modern computing.

How is a colour like #FF8800 a number? It is three separate one-byte numbers stitched together: red = FF (255), green = 88 (136), blue = 00 (0). Each channel is a hex value from 00 to FF describing that colour’s intensity. The colour mixer works directly with these hex triples.

Related calculators

Pair the hex calculator with these tools for the rest of a number-crunching workflow.

  • Binary calculator — add, subtract, multiply, divide, and run bitwise AND/OR/XOR, with every result shown in binary, decimal, and hex.
  • Colour mixer — blend two hex or RGB colours with an adjustable share and read off the mixed hex, RGB, and HSL.
  • IP subnet calculator — work with IPv4 addresses and CIDR prefixes, including the binary form of the address and mask.
  • Exponent calculator — compute the powers of two and sixteen that set each column weight in a base conversion.

Frequently asked questions

What is hexadecimal in simple terms?

It is a way of writing numbers using sixteen symbols instead of ten: the digits 0–9 plus the letters A–F for the values ten through fifteen. It represents exactly the same quantities as decimal — just more compactly for computer data, because one hex digit stands in for four binary bits.

How do I convert hex to decimal by hand?

Multiply each hex digit by 16 raised to its position (counting from 0 on the right) and add the results. For 2F: (2 × 16¹) + (15 × 16⁰) = 32 + 15 = 47. Substitute A=10 through F=15 for the letter digits before multiplying.

Why do programmers use hexadecimal?

Because it is a clean shorthand for binary. Every four bits map to exactly one hex digit and every byte to exactly two, so a block of raw data that would be an unreadable wall of 0s and 1s in binary becomes a short, scannable string in hex. Memory addresses, byte values, colours, and hashes are all shown in hex for this reason.

What does the 0x prefix mean?

It signals that the following digits are hexadecimal. 0xFF is the hex number FF, which equals decimal 255. The related prefixes are 0b for binary and 0o for octal. The hex calculator accepts and displays all three.

What is the largest number in one byte, and why is it 255?

A byte is eight bits, and eight bits give 2⁸ = 256 combinations, running from 0 to 255. In hex that maximum is FF and in binary 11111111. Add one more and it rolls over to 256 (0x100), which needs a ninth bit.

What is the difference between a bit, a nibble, and a byte?

A bit is a single binary digit (0 or 1). A nibble is four bits and maps to exactly one hex digit (0–F). A byte is eight bits — two nibbles — and maps to two hex digits (00–FF), holding values 0 to 255.

Is octal still used for anything?

Mainly Unix and Linux file permissions, where a command such as chmod 644 uses three octal digits to set read, write, and execute bits for owner, group, and others. Outside that, hex has largely replaced octal in modern computing.

How is a colour like #FF8800 a number?

It is three separate one-byte numbers stitched together: red = FF (255), green = 88 (136), blue = 00 (0). Each channel is a hex value from 00 to FF describing that colour’s intensity. The colour mixer works directly with these hex triples.

Informational only. Not personalised financial, legal, or tax advice.