Understand binary, octal, decimal, and hexadecimal number systems

Decimal vs hexadecimal vs binary (and octal): what changes when you convert, when each base is the right choice, and what survives copying and sharing.

Decimal, binary, octal and hexadecimal are four ways of writing the same quantity. Converting between them is a text transformation in the literal sense. The characters change but the value stays the same, provided the reader knows which base is being used. This review explains what each system is, what a conversion actually changes, when each one suits the job, and what holds up when the result is copied or shared.

The short answer: when is each number system the right choice?

Hexadecimal suits showing bytes, memory addresses, colour codes and character code points to a technical audience. It is compact and lines up exactly with binary. Binary is the better choice only when individual bits matter, such as flags, bit masks or teaching how storage works. Octal has a narrow modern role, mainly Unix file permissions. Decimal is the right default for anything meant for general readers, including counts, prices and measurements.

The decisive tradeoff is alignment with bits versus readability for non-specialists. Plain text is preferable whenever the content is words meant for people. Encoding a sentence as binary or hex hides it from readers, search and assistive technology. It also provides no secrecy, because anyone can decode it instantly. Treat it as a novelty or a technical representation, not as formatting or protection.

What the four number systems are

All four are positional systems. Each digit's value depends on its position, and each position is worth the base raised to a power. The base sets how many distinct digits exist before a new position is needed.

System | Base | Digits | Common markers | Typical use
Decimal | 10 | 0–9 | none | everyday quantities
Binary | 2 | 0, 1 | 0b prefix | bits, flags, masks
Octal | 8 | 0–7 | 0o prefix, or a leading 0 in some languages | Unix permissions such as 755
Hexadecimal | 16 | 0–9, A–F | 0x prefix, # for colours, U+ for Unicode code points | bytes, addresses, colours, character codes

Here is one worked example. Hex 2F is 2×16 + 15 = 47. Binary 101111 is 32 + 8 + 4 + 2 + 1 = 47. Octal 57 is 5×8 + 7 = 47. All three are the same number written differently.

Decimal  Binary          Octal  Hex
10       1010            12     A
47       101111          57     2F
255      11111111        377    FF
4096     1000000000000   10000  1000

How binary and hexadecimal differ

The key relationship is that one hex digit stands for exactly four binary digits. Two hex digits therefore describe one 8-bit byte. This is why hex is the standard shorthand for binary: you can convert one group of four bits at a time without any arithmetic on the whole number. Octal digits each represent three bits. Three does not divide evenly into an 8-bit byte, which is a large part of why hex replaced octal for most byte-oriented work.

Binary, grouped in 4s:   1101 0110
Hex, one digit per group:   D    6    -> D6

Binary, grouped in 3s:  11 010 110
Octal, one digit per group: 3   2   6   -> 326

All three equal decimal 214

Decimal vs hexadecimal vs binary: length and readability

Writing a single byte (0 to 255) takes up to 3 decimal digits, exactly 2 hex digits, or 8 binary digits. Binary is the most explicit form and the hardest to scan, because errors such as a missing or doubled digit are easy to make and hard to spot. Decimal is the most familiar, but its digits do not map to bit boundaries, so it obscures structure such as which flags are set. Hex sits in between: it is compact and bit-aligned, but it is unfamiliar to many readers, and its letters A–F can be mistaken for words or typos.

Hex in numbers, and what people mean by a 'hex data type'

In most programming languages, hexadecimal is a notation rather than a separate data type. The literals 0xFF and 255 produce the same stored integer, and only the source text differs. When people refer to a 'hex data type', they usually mean one of three different things:
1) An integer written in hex notation.
2) A string of hex characters that represents bytes, such as a checksum or an encoded file.
3) A binary or byte column that a database or tool displays as hex.

The difference matters. The string 'FF' is two text characters, not the number 255, until something parses it. Hex digits are case-insensitive as values, so ff and FF mean the same thing. Code that compares the strings exactly may still treat them as different.

What the transformation actually changes

Base conversion changes the stored characters. This is unlike font styling or CSS presentation, which change only how existing characters look. The value is preserved but its label is not. The string 10 means ten, two, eight or sixteen depending on the base, so a converted number without a prefix or a stated base has effectively lost part of its meaning.

Two different operations are often both called 'converting to binary' or 'converting to hex'. The first is rewriting a number in another base. The second is encoding text as numbers. The second depends on a character encoding, and the same visible text can produce different output:

Text: Hi
UTF-8 bytes (hex):      48 69
UTF-8 bytes (binary):   01001000 01101001
UTF-8 bytes (decimal):  72 105

Text: é  (single precomposed character)
Unicode code point:     U+00E9 (decimal 233)
UTF-8 bytes (hex):      C3 A9
UTF-8 bytes (binary):   11000011 10101001

Text: é  (e followed by a combining acute accent)
Unicode code points:    U+0065 U+0301
UTF-8 bytes (hex):      65 CC 81

Text: 😀
Unicode code point:     U+1F600
UTF-8 bytes (hex):      F0 9F 98 80

The examples show several consequences. One visible character can become one, two, three or four bytes. Two strings that look identical can encode differently, as the two forms of é do. Many emoji are sequences of several code points, which produces even longer output. Decoding only works if the reader uses the same encoding. A mismatch produces garbled characters rather than an error message.

Binary carries some additional ambiguities.
• Bit width: leading zeros do not change a value, but they show the intended width. For example, 101 and 00000101 are both five, and only the second signals a byte.
• Signedness: 11111111 is 255 as an unsigned byte but −1 as a signed 8-bit value in two's complement.
• Leading zeros in code: some programming languages read a leading zero as octal, so 010 means eight. Others reject that form or read it as ten.

Will the result stay readable and usable after copying or sharing?

Converted numbers use only ASCII digits, the letters A–F and occasionally x, b or o. That means they paste as ordinary characters almost anywhere, unlike decorative Unicode letter styles. The risks lie less in the characters themselves than in how the destination interprets them:

  • Spreadsheets and data tools may treat a hex or binary string as a number. They can drop leading zeros or read a hex value such as 1E5 as scientific notation. Import the column as text where the tool allows it, then check the values afterwards.
  • Context is easily lost. A value pasted without its prefix or a stated base cannot be interpreted reliably.
  • Long binary strings may wrap mid-byte, and spaces between groups may be stripped or added when the text is reformatted.
  • Changing letter case is harmless for hex values but can break exact string comparisons, such as checksum checks.
  • Search engines and in-page search find encoded text only by its digits, not by the words it represents.
  • Hand-editing is error-prone. One wrong digit changes a whole byte, and in encoded text it can produce an invalid character sequence.

Screen readers can announce long digit strings in several ways, depending on the product and its settings: as a large number, digit by digit, or in groups. No scoped test with a named assistive technology was supplied for this review, so no claim is made about any specific screen reader. Regardless of the product, a long run of ones and zeros is difficult to follow by ear. Whenever the encoded content carries meaning, provide the plain-text or decimal equivalent next to it and label the base. Messages, social posts, alt text and interface labels should use plain text unless the audience is expected to decode the content.

Practical checklist

  • Mark the base with a prefix (0x, 0b, 0o) or a clear label.
  • For binary, state the bit width and whether the value is signed.
  • For encoded text, name the character encoding, which is usually UTF-8.
  • Group digits so they are easy to read: hex in byte pairs, binary in groups of four or eight.
  • Keep a decimal or plain-text version for general readers and assistive technology.
  • Test the round trip in the actual destination before relying on it.

Limits of this review

The number conversions shown above are arithmetic and can be checked by hand. How spreadsheets, editors and other destinations interpret the output varies by product and version, and no destination was tested for this review. The spreadsheet points above are risks to check, not verified results. No specific converter tool was evaluated either. Check a tool's own documentation for how it handles your data before pasting anything sensitive into it.