UtilsDaily

Number Base Converter

Convert numbers between Binary, Octal, Decimal, and Hexadecimal (Base 2, 8, 10, 16). Instant conversion with explanation.

Type a number in any field — all other bases update automatically.

Base 10
Decimal
Base 2
Binary
Base 16
Hexadecimal
Base 8
Octal

Conversion steps — Decimal 255

255 in binary: divide by 2 repeatedly 255 ÷ 2 = 127 R 1 127 ÷ 2 = 63 R 1 63 ÷ 2 = 31 R 1 31 ÷ 2 = 15 R 1 15 ÷ 2 = 7 R 1 7 ÷ 2 = 3 R 1 3 ÷ 2 = 1 R 1 1 ÷ 2 = 0 R 1 Reading remainders bottom-to-top: 11111111

What Are Number Bases?

A number base (or radix) is the number of unique digits a positional numeral system uses. The base determines how digit position relates to value. In base 10 (decimal), each position is 10× more valuable than the position to its right. In base 2 (binary), each position is 2× more valuable.

The four number bases used in computing are:

  • Binary (base 2): Uses only digits 0 and 1. This is the native language of all digital hardware.
  • Octal (base 8): Uses digits 0–7. Historically used in older programming systems; still used for Unix file permissions.
  • Decimal (base 10): Uses digits 0–9. The everyday number system humans use.
  • Hexadecimal (base 16): Uses digits 0–9 and A–F. Compact representation of binary data used in programming, color codes, memory addresses.

How Binary (Base 2) Works

Binary is the fundamental number system of all digital computers. Each binary digit ("bit") represents one of two states: 0 (off) or 1 (on). Modern computers group bits into bytes (8 bits), and everything — text, images, programs — is ultimately stored as sequences of bytes.

Positional values in binary:

Position 7 6 5 4 3 2 1 0
Value (2ⁿ) 128 64 32 16 8 4 2 1
Example: 42 0 0 1 0 1 0 1 0

42 in binary = 0b101010. Calculation: 32+0+8+0+2+0 = 42 ✓

Hexadecimal in Practice

Hexadecimal (hex) is the standard way to represent binary data in a human-readable compact form. Each hex digit represents exactly 4 binary bits:

Decimal Hex Binary (4 bits) Decimal Hex Binary (4 bits)
000000881000
110001991001
10A101013D1101
11B101114E1110
12C110015F1111

Real-world hex examples:

  • Web colors: #FF5733 = R:255, G:87, B:51. Each pair of hex digits is one byte (0–255).
  • Memory addresses: 0x7FFF5FBFF758 — the 0x prefix indicates hex in most programming languages.
  • MAC addresses: 00:1A:2B:3C:4D:5E — six bytes written in hex.
  • SHA256 hashes: 64 hex characters = 32 bytes = 256 bits of data.

The Relationship Between Bases

The elegance of binary, octal, and hex is that they are all powers of 2, which means conversion between them does not require division — just grouping:

  • 1 octal digit = exactly 3 binary bits (2³ = 8)
  • 1 hex digit = exactly 4 binary bits (2⁴ = 16)
  • 2 hex digits = 1 byte = 8 binary bits

To convert binary to hex: group from the right in sets of 4 bits. Binary 10111110 → 1011 (B) + 1110 (E) = 0xBE.

Frequently Asked Questions

Why do computers use binary instead of decimal?

Physical hardware is most reliable when it distinguishes between two states (on/off, high/low voltage). Implementing 10 distinct voltage levels reliably and at scale is impractical. Binary hardware is fast, reliable, and cheap to manufacture. The mathematical elegance is a bonus — not the reason.

What does 0xFF mean in programming?

0xFF is hexadecimal 255 (decimal). The "0x" prefix is the standard notation for hexadecimal literals in most programming languages (C, C++, Java, JavaScript, Python, etc.). FF in hex = 1111 1111 in binary = 255 in decimal. It represents the maximum value of a single byte and is commonly used as a bit mask, RGB color value, or to represent "all bits set".

What does 0b mean in code?

The "0b" prefix indicates a binary literal in Python, JavaScript (ES6+), C++14, and other modern languages. For example, 0b1010 = decimal 10. This lets you write bit patterns directly in source code without mentally converting to decimal or hex.

How is this different from the Number() function in JavaScript?

JavaScript's parseInt() function already handles base conversion: parseInt("FF", 16) returns 255, and (255).toString(16) returns "ff". This online tool provides the same conversion with a visual interface and step-by-step explanation, useful for learning and for quick checks without writing code.

What is the largest number representable in 8 bits (one byte)?

In unsigned representation: 2⁸ − 1 = 255 (decimal) = 0xFF (hex) = 11111111 (binary). In signed two's complement representation (where one bit is used for the sign): the range is −128 to 127. The byte boundary of 255 is why web colors range from 0 to 255 per channel, and why IPv4 address octets range from 0 to 255.

Embed This Tool on Your Website