Skip to content
UPEEC

Number Systems

Binary, octal, decimal and hexadecimal — and converting between them.

Beginner
Comments 0
DecimalBinaryHex
000000
501015
101010A
151111F
2551111 1111FF

To convert decimal to binary, divide by 2 repeatedly and read the remainders bottom-up. Each hex digit is exactly 4 bits, so hex is a compact way to write binary: 0x3F = 0011 1111.

In code: 0b1010 (binary), 0x1F (hex), 017 (octal in C — a common surprise!).

Sub-topics (2)

BCD and Gray Code

Binary-coded decimal stores each decimal digit in 4 bits; Gray code changes only one bit between consecutive values.

Easy♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.