๐ข Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal instantly. Supports large numbers and shows all bases simultaneously. Free online number base converter.
How to Use
Enter any number
Type a number into any of the four fields: Decimal, Binary, Hexadecimal, or Octal.
All bases update instantly
The other three fields automatically update with the equivalent value in real-time.
Copy any format
Click the Copy button next to any field to copy that representation to your clipboard.
Frequently Asked Questions
Complete Guide: Number Base Converter
Computers store and process all data as binary โ sequences of 0s and 1s. But binary is verbose and difficult for humans to read. Programmers regularly work with hexadecimal (base 16) and occasionally octal (base 8) as more compact representations of the same underlying bit patterns. Understanding number base conversions is fundamental to low-level programming, networking, color theory, and cryptography.
Positional Notation: The Core Concept
In any positional number system, each digit's value depends on its position. In base 10 (decimal), the number 253 means (2 ร 10ยฒ) + (5 ร 10ยน) + (3 ร 10โฐ) = 200 + 50 + 3. The same principle applies to any base. Binary 1011 means (1 ร 2ยณ) + (0 ร 2ยฒ) + (1 ร 2ยน) + (1 ร 2โฐ) = 8 + 0 + 2 + 1 = 11 decimal. Hexadecimal uses digits 0โ9 then AโF, where A=10, B=11, C=12, D=13, E=14, F=15.
Why Programmers Love Hexadecimal
The key insight is that one hexadecimal digit represents exactly four binary digits (a nibble). This means one byte (8 bits) maps to exactly two hex digits. For example, the binary value 11111111 is FF in hex and 255 in decimal. This compact mapping makes it easy to inspect raw memory, define colors, and work with cryptographic hashes without the verbosity of binary.
Two's Complement for Negative Numbers
Computers represent negative integers using two's complement. To find the two's complement of a number: invert all bits, then add 1. For an 8-bit representation, -1 is 11111111 (0xFF), and -128 is 10000000 (0x80). The most significant bit (leftmost) serves as the sign bit โ 1 means negative, 0 means positive. This is why a signed 8-bit integer ranges from -128 to 127, while an unsigned 8-bit integer ranges from 0 to 255.
Bit Shifting Operations
Bit shifting is effectively multiplication or division by powers of 2:
- Left shift (
<<):5 << 1= 10 (multiply by 2) - Right shift (
>>):20 >> 2= 5 (divide by 4)
Bit shifting is commonly used in graphics pipelines, compression algorithms, and bitfield manipulation where speed matters.
Color Hex to RGB Conversion
CSS hex colors like #1A2B3C encode three pairs of hex digits, each representing one color channel. Split the six digits into pairs: 1A, 2B, 3C. Convert each pair from hex to decimal: 0x1A = 26, 0x2B = 43, 0x3C = 60. The result is rgb(26, 43, 60). The shorthand #RGB format doubles each digit: #ABC = #AABBCC.
IPv4 Addresses in Hex
IPv4 addresses are four bytes. The loopback address 127.0.0.1 in hex is 7F.00.00.01. Network engineers and low-level socket programmers often encounter IP addresses stored as 32-bit integers in hex, especially in packet dumps and kernel source code.
JavaScript: parseInt and toString
JavaScript provides built-in base conversion:
// String of any base to decimal integer
parseInt('FF', 16); // 255
parseInt('1010', 2); // 10
parseInt('17', 8); // 15
// Decimal integer to string of any base
(255).toString(16); // "ff"
(10).toString(2); // "1010"
(255).toString(8); // "377"
Be careful: parseInt silently ignores invalid characters after the last valid digit rather than throwing an error. Always validate input before calling it.
For converting hex color values interactively, see the Color Picker. For computing hex-encoded hash values, use the Hash Generator.