0xCONVERTER-HEX

Guide

Hex vs Decimal

Same numbers, different questions answered. Which notation belongs where.

The difference in one line

Decimal tells you how much. Hex tells you which bits.

Both describe identical values. What differs is what the notation makes obvious and what it hides.

DecimalHexadecimal
Base1016
Digits0–90–9, A–F
Bits per digitAbout 3.32 — not a whole numberExactly 4
One byte0–255, one to three digits00–FF, always two digits
Makes obviousMagnitude and arithmeticBit patterns and byte boundaries
HidesWhich bits are setRough size at a glance

The fixed-width property

This is the practical difference, and it matters more than it sounds.

four bytes in decimal   26  115  232  9
four bytes in hex       1A   73   E8  09

decimal:  widths vary — you must count carefully
hex:      always two digits — boundaries are automatic

In a dump of a thousand bytes, hex columns line up perfectly and decimal columns do not. That is why every debugger, hex editor and packet analyser ever written displays hex.

Where decimal wins

  • Quantities people care about. Prices, counts, measurements, ages. Nobody wants their bank balance in hex.
  • Mental arithmetic. You have practised base 10 since childhood.
  • Anything user-facing. Error codes shown to non-technical users, quantities in a UI, numbers in documentation aimed at a general reader.
  • Rough comparison. You can see instantly that 1,000,000 is much bigger than 50,000. F4240 versus C350 takes a moment longer.

Where hex wins

  • Anything bit-related. Masks, flags, permissions, packed fields.
  • Memory addresses. Alignment is visible — an address ending in 0 is 16-byte aligned, and you can see that without dividing.
  • Fixed-width data. Bytes, words, registers, protocol fields.
  • Identifiers. Hashes, UUIDs, MAC addresses. Compact and unambiguous.
  • Color codes. Three bytes in six characters, with the channel split visible.
The alignment example

Is address 3,735,928,560 aligned to a 16-byte boundary? You would have to divide. Is DEADBEF0? Yes — the last digit is 0, and that is the whole check. This is the kind of question hex answers for free.

Side by side

DecimalHexWhich is clearer, and why
255FFHex — obviously a full byte
1,0003E8Decimal — a round human number
16,777,215FFFFFFHex — obviously three full bytes
4,294,967,295FFFFFFFFHex — obviously a 32-bit maximum
3,600E10Decimal — it is an hour in seconds
12880Hex — obviously just the sign bit

The pattern: if the number is meaningful to a person, decimal. If it is meaningful to the machine, hex.

Choosing in code

Most languages accept both and produce identical machine code, so the choice is purely about the reader.

// hex — the value is a bit pattern
flags &= 0xF0;
if (status & 0x80) { ... }
color = 0x1A73E8;

// decimal — the value is a quantity
if (retries > 3) { ... }
timeout = 5000;
for (int i = 0; i < 256; i++) { ... }

Writing flags &= 240 is legal and tells the reader nothing. Writing timeout = 0x1388 is also legal and equally unhelpful. Match the notation to what the number means.

Converting between them

Use the hex to decimal converter or the decimal to hex converter, or work through the methods by hand in the conversion tutorial.

Frequently asked questions

What is the difference between hex and decimal?

Decimal uses ten digits and hex uses sixteen. They express the same values, but hex makes bit patterns and byte boundaries visible while decimal makes magnitude easier to judge.

Why do programmers use hex instead of decimal?

Because one hex digit is exactly four bits and one byte is exactly two hex digits. Byte boundaries stay visible, which decimal cannot do.

Is hex faster for a computer?

No. The computer works in binary either way. The choice affects only human readability.

When should I write decimal in my code?

Whenever the number is a quantity: counts, limits, timeouts, sizes people reason about.

When should I write hex in my code?

Whenever the number is a bit pattern: masks, flags, addresses, color codes, protocol constants.

Which is bigger, FF or 255?

Neither. They are the same number written in two notations.