the IT Hustle
工具实战手册关于
FundamentalsAI辅助2026-04-17•9 min 阅读

Hex to Decimal: Number Systems Explained Simply

作者: Salty Deprecated Software Engineer

✨ AI 辅助内容

本文由 AI 辅助创作,并经团队审核以确保准确性和质量。所有技术信息和示例均已验证。

You've seen hex color codes in CSS. You've seen 0xFF in low-level code. You've seen binary in networking documentation. These aren't different languages — they're different ways of writing the same numbers. Once that clicks, everything gets easier.

This guide explains the four number bases you'll encounter in computing: binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). No math degree required.

Why Computers Don't Use Decimal

Humans evolved using base 10 because we have 10 fingers. Computers use base 2 because transistors have two states: on and off. Every number your computer stores is ultimately a sequence of ones and zeros.

Binary (base 2). Uses digits 0 and 1. Every modern computer works in binary at the hardware level.
Octal (base 8). Uses digits 0–7. Appears in Unix file permissions (chmod 755) and older systems.
Decimal (base 10). Uses digits 0–9. The base humans use. What you see in most UIs.
Hexadecimal (base 16). Uses digits 0–9 and letters A–F. Shorthand for binary — one hex digit = four binary bits.

The number 255 is the same number in all four systems — it's just written as 11111111 in binary, 377 in octal, 255 in decimal, and FF in hex.

How Decimal Works (The Model for Everything)

In decimal, each digit position represents a power of 10:

The number 347:

3 × 10² = 3 × 100 = 300

4 × 10¹ = 4 × 10 = 40

7 × 10⁰ = 7 × 1 = 7

Total: 347

Every other number system works the same way — just with a different base instead of 10. Binary uses powers of 2. Hex uses powers of 16. Once you internalize this, converting between bases becomes mechanical.

Binary: The Foundation

Binary uses only 0 and 1. Each digit position is a power of 2:

Binary 1011 to decimal:

1 × 2³ = 1 × 8 = 8

0 × 2² = 0 × 4 = 0

1 × 2¹ = 1 × 2 = 2

1 × 2⁰ = 1 × 1 = 1

Total: 8 + 0 + 2 + 1 = 11

To convert decimal to binary, repeatedly divide by 2 and track the remainders:

Decimal 13 to binary:

13 ÷ 2 = 6 remainder 1 ← least significant bit

6 ÷ 2 = 3 remainder 0

3 ÷ 2 = 1 remainder 1

1 ÷ 2 = 0 remainder 1 ← most significant bit

Read remainders bottom-up: 1101

Key binary reference points every developer should know: 8 bits = 1 byte, max value 255 (11111111). 16 bits = max 65,535. 32 bits = max ~4.3 billion.

Hexadecimal: Binary's Readable Sibling

Binary is unwieldy. The number 255 in binary is eight digits: 11111111. Hex condenses it to two: FF. That's why hex is used everywhere binary is used — it's human-readable shorthand.

Hex uses 16 symbols: 0–9 and A–F (A=10, B=11, C=12, D=13, E=14, F=15).

Hex to decimal reference:

0–9 → 0–9 (same as decimal)

A → 10

B → 11

C → 12

D → 13

E → 14

F → 15

10 → 16

FF → 255

100 → 256

To convert hex to decimal, use powers of 16:

Hex 2A to decimal:

2 × 16¹ = 2 × 16 = 32

A × 16⁰ = 10 × 1 = 10

Total: 32 + 10 = 42

Where You'll Actually See Each Base

Hexadecimal in the wild:
  • CSS colors: #FF5733 (R=255, G=87, B=51)
  • Memory addresses: 0x7fff5fbff8e0
  • Unicode code points: U+1F600 (😀)
  • SHA hashes and UUIDs
  • MAC addresses: 00:1A:2B:3C:4D:5E
Binary in the wild:
  • Network subnet masks: 11111111.11111111.11111111.00000000
  • Bitwise operations in code
  • Flags and permission bitmasks
Octal in the wild:
  • Unix file permissions: chmod 755 (rwxr-xr-x)
  • Legacy C/C++ integer literals: int x = 0777;

The Hex-Binary Shortcut

One hex digit always equals exactly four binary bits (a nibble). This makes converting between hex and binary trivial:

Hex to binary — convert each digit independently:

F = 15 = 1111

A = 10 = 1010

3 = 3 = 0011

FA3 in binary = 1111 1010 0011

This is why programmers use hex — it's direct shorthand for binary without the verbosity.

Converting in Code

You almost never convert by hand in practice. Every programming language has built-in functions:

JavaScript / TypeScript:

parseInt("FF", 16) // hex to decimal → 255

parseInt("1011", 2) // binary to decimal → 11

parseInt("377", 8) // octal to decimal → 255

(255).toString(16) // decimal to hex → "ff"

(255).toString(2) // decimal to binary → "11111111"

(255).toString(8) // decimal to octal → "377"

Python:

int("FF", 16) # hex to decimal → 255

int("1011", 2) # binary to decimal → 11

hex(255) # decimal to hex → "0xff"

bin(255) # decimal to binary → "0b11111111"

oct(255) # decimal to octal → "0o377"

CSS Colors: A Practical Hex Exercise

CSS hex colors are three pairs of hex digits — one pair each for red, green, and blue:

#FF5733 decoded:

FF = 255 → Red at full intensity

57 = 87 → Green at 34%

33 = 51 → Blue at 20%

The shorthand #F00 expands to #FF0000 — pure red. The 3-digit form works when both digits in each pair are identical.

Try it yourself

Use our free Number Base Converter to convert between decimal, binary, octal, and hexadecimal instantly — paste any number in any base and see all the equivalents.

Quick Reference Table

DecimalBinaryOctalHex
0000
1111
21022
410044
81000108
10101012A
15111117F
16100002010
321000004020
64100000010040
1281000000020080
25511111111377FF
256100000000400100

The One Thing to Remember

Different bases are just different notations for the same underlying number. 255 = 0xFF = 0b11111111 = 0o377. They're identical values written in different scripts.

You don't need to master hand conversion. You do need to recognize hex when you see it, understand that CSS color #00FF88 is three bytes, and know that chmod 755 is octal. The rest is Google and parseInt().

IT
Salty Deprecated Software Engineer

以 The IT Hustle 的编辑笔名写作——25 年以上笔记本维修技师、系统管理员、存储工程师和软件工程师的经验,如今用在 AI 智能体运维上。每篇文章发布前都经过人工审核,详见编辑准则。

我们的工具全部文章关于我们

获取最新资讯

第一时间了解新工具、博客文章和更新动态。无垃圾邮件。

生成专属防幻觉提示词

AI 提示词引擎采用专有技术,生成内置验证和矛盾测试的提示词。

免费试用 3 次 →

公司

  • 关于
  • 实战手册
  • AI 术语表
  • 关于作者
  • 联系我们

产品

  • 工具
  • 价格观察
  • 智能体运维
  • 编程
  • 设计
  • 运维
  • 效率
  • 营销
  • 商务

法律信息

  • 隐私政策
  • 服务条款
  • 免责声明
  • 编辑准则
  • 更正说明

© 2026 Salty Rantz LLC. 版权所有。

为在技术变革中前行的职场人打造。