Number Base Converter

Convert numbers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) instantly. Perfect for programmers, students, and anyone working with different number systems.

Only 0 and 1
Digits 0-7
Digits 0-9
Digits 0-9, A-F

๐Ÿš€ Quick Conversions

What is a Number Base Converter?

A number base converter is a tool that transforms numbers between different numeral systems (bases). The most common bases are binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Each base uses a different set of digits to represent numbers. Understanding number bases is essential for computer science, programming, digital electronics, and mathematics.

Number Systems Explained

Binary (Base 2)

Uses only two digits: 0 and 1. This is the fundamental language of computers, where each digit represents a bit (binary digit). All computer data is ultimately stored and processed as binary.

Example: 1010โ‚‚ = (1ร—2ยณ) + (0ร—2ยฒ) + (1ร—2ยน) + (0ร—2โฐ) = 8 + 0 + 2 + 0 = 10โ‚โ‚€

Octal (Base 8)

Uses eight digits: 0-7. Historically used in computing as a more compact way to represent binary. Each octal digit represents exactly 3 binary digits.

Example: 12โ‚ˆ = (1ร—8ยน) + (2ร—8โฐ) = 8 + 2 = 10โ‚โ‚€

Decimal (Base 10)

Uses ten digits: 0-9. This is the standard number system we use in everyday life. It's called decimal because "deci" means ten.

Example: 255โ‚โ‚€ = (2ร—10ยฒ) + (5ร—10ยน) + (5ร—10โฐ) = 200 + 50 + 5 = 255โ‚โ‚€

Hexadecimal (Base 16)

Uses sixteen digits: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Widely used in computing because each hex digit represents exactly 4 binary digits (one nibble).

Example: FFโ‚โ‚† = (15ร—16ยน) + (15ร—16โฐ) = 240 + 15 = 255โ‚โ‚€

Common Use Cases

  • Programming: Working with bitwise operations, memory addresses, and low-level code
  • Color Codes: Converting RGB colors to hexadecimal (e.g., #FF5733)
  • Networking: IP addresses, MAC addresses, and subnet masks
  • Digital Electronics: Logic circuits and microcontroller programming
  • Computer Science: Learning algorithms, data structures, and computer architecture
  • Debugging: Analyzing memory dumps and register values
  • Cryptography: Working with encryption keys and hash values
  • Assembly Language: Reading and writing machine code
  • File Formats: Analyzing binary file structures and hex editors
  • Mathematics: Understanding number theory and different bases

Binary Relationships

Decimal Binary Octal Hexadecimal
0000000
81000108
15111117F
16100002010
25511111111377FF
1024100000000002000400

Features

  • Live Conversion: All bases update automatically as you type
  • 4 Number Systems: Binary, octal, decimal, and hexadecimal
  • Binary Analysis: View bit count, byte count, and binary representation
  • Quick Conversions: Preset buttons for common values
  • Input Validation: Only accepts valid digits for each base
  • Large Numbers: Support for large integer values
  • Bit Grouping: Binary displayed in groups of 4 for readability
  • Case Insensitive: Hexadecimal accepts both uppercase and lowercase
  • Fast Performance: Instant conversion with no delays
  • Privacy Focused: All conversion happens in your browser

Programming Examples

JavaScript

// Decimal to other bases
let num = 255;
console.log(num.toString(2));   // "11111111" (binary)
console.log(num.toString(8));   // "377" (octal)
console.log(num.toString(16));  // "ff" (hexadecimal)

// Other bases to decimal
console.log(parseInt("11111111", 2));   // 255
console.log(parseInt("377", 8));        // 255
console.log(parseInt("FF", 16));        // 255

Python

# Decimal to other bases
num = 255
print(bin(num))   # "0b11111111" (binary)
print(oct(num))   # "0o377" (octal)
print(hex(num))   # "0xff" (hexadecimal)

# Other bases to decimal
print(int("11111111", 2))   # 255
print(int("377", 8))        # 255
print(int("FF", 16))        # 255

C/C++

int num = 255;

// Print in different bases
printf("Decimal: %d\n", num);       // 255
printf("Octal: %o\n", num);         // 377
printf("Hex: %x\n", num);           // ff
printf("Hex (upper): %X\n", num);   // FF

// Parse from different bases
int binary = 0b11111111;            // 255 (C++14+)
int octal = 0377;                   // 255
int hex = 0xFF;                     // 255

Common Bit Values

  • 8 bits (1 byte): 0-255 (0x00-0xFF)
  • 16 bits (2 bytes): 0-65,535 (0x0000-0xFFFF)
  • 32 bits (4 bytes): 0-4,294,967,295 (0x00000000-0xFFFFFFFF)
  • 64 bits (8 bytes): 0-18,446,744,073,709,551,615

Tips & Tricks

  • To quickly convert hex to binary, replace each hex digit with 4 binary digits
  • Each octal digit represents exactly 3 binary digits
  • Use hexadecimal for shorter representation of binary data
  • Powers of 2 in decimal (1, 2, 4, 8, 16, 32, 64, 128, 256...) are easy to spot in binary
  • Hex F (15) in binary is always 1111, A (10) is 1010, etc.
  • To check if a number is a power of 2: in binary, it has only one '1' bit
  • Leading zeros don't change the value (0xFF = 0x00FF = 0x0000FF)

Frequently Asked Questions

Why do programmers use hexadecimal?

Hexadecimal is more compact than binary (4 bits per digit vs 1 bit) while still mapping directly to binary. It's easier to read and write than long binary strings, making it perfect for memory addresses, color codes, and debugging.

What's the difference between 0x and 0b prefixes?

In programming, 0x prefix indicates hexadecimal (e.g., 0xFF), 0b indicates binary (e.g., 0b1111), and 0 prefix indicates octal (e.g., 077). These prefixes help the compiler/interpreter identify the number base.

How many bytes is a hexadecimal pair like FF?

Two hexadecimal digits represent exactly 1 byte (8 bits). So FF = 11111111 in binary = 1 byte. This is why hex is commonly used in byte-oriented systems.

Can I convert negative numbers?

This tool works with positive integers. For negative numbers, computers use representations like two's complement, which requires specifying the bit width (8-bit, 16-bit, etc.).

Is my data stored or sent to a server?

No, all conversions happen entirely in your browser using JavaScript. Your numbers never leave your device and are not stored anywhere.