Base Conversion Calculator
Convert a whole number into binary, octal, decimal, and hexadecimal.
How to use this base conversion calculator
- Enter the whole number
Type a non-negative integer into the Whole number field (e.g. 255 or 4096).
- Read the binary value
The Binary value result shows the base-2 representation.
- Check octal and hex
Review the Octal and Hexadecimal results for compact representations.
- Verify decimal
The Decimal output confirms the original value for cross-checking.
How this base conversion calculator works
This base conversion calculator takes a whole number in decimal (base 10) and represents it in binary (base 2), octal (base 8), and hexadecimal (base 16) — the four numeral systems most frequently used in computing. Every positional number system works the same way: each digit position represents a successive power of the base, and the value of the number is the sum of each digit multiplied by its positional weight. Converting between bases is a fundamental operation in low-level programming, digital logic design, network engineering (MAC and IPv6 addresses), color codes in CSS, file-permission masks in Unix, and memory-address inspection during debugging.
Repeated division: divide N by the target radix R, record the remainder, repeat with the quotient until it reaches 0, then read the remainders in reverse order Convert the decimal number 255 to binary, octal, and hexadecimal. For binary (R = 2): 255 ÷ 2 = 127 remainder 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-up: 11111111. For octal (R = 8): 255 ÷ 8 = 31 R 7, 31 ÷ 8 = 3 R 7, 3 ÷ 8 = 0 R 3 → 377. For hexadecimal (R = 16): 255 ÷ 16 = 15 R 15 (F), 15 ÷ 16 = 0 R 15 (F) → FF.
Decimal 4096 → binary 1000000000000, octal 10000, hex 1000. Useful for understanding 4 KiB = 4096 bytes.
Decimal 15 → binary 1111, octal 17, hex F. Each hex digit maps to exactly four bits; F = 1111.
- ✓ The input is a non-negative whole number (zero or positive integer). Fractional values and negative numbers require extended algorithms (e.g., two's complement for signed binary) that are outside this tool's scope.
- ✓ Hexadecimal digits above 9 are represented using uppercase letters A–F, following the convention in most programming languages, RFCs, and hardware documentation.
- ✓ Leading zeros are omitted from the output. For fixed-width representations (e.g., 8-bit or 32-bit binary), pad the result manually to the desired width.
- ✓ The calculator accepts non-negative whole numbers only. Values above 2^53 − 1 (JavaScript's Number.MAX_SAFE_INTEGER) are rejected so the displayed digits stay exact.
- Each hexadecimal digit maps to exactly four binary digits (bits), and each octal digit maps to exactly three bits. This relationship makes mental conversion between hex, octal, and binary fast once you memorize the 16 nibble patterns.
- Common values worth memorizing: 0xFF = 255, 0x100 = 256, 0xFFFF = 65535, 0xFFFFFFFF = 4,294,967,295 (the maximum unsigned 32-bit integer).
- Unix file permissions use octal: 755 means rwxr-xr-x (owner read/write/execute, group and others read/execute). Each octal digit encodes three permission bits.
- CSS hex color codes are three concatenated hexadecimal byte values representing red, green, and blue channels — e.g., #FF8800 is 255 red, 136 green, 0 blue.
- Positional numeral system theory — Knuth, D. E., The Art of Computer Programming, Volume 2: Seminumerical Algorithms, Section 4.1
- IEEE 754-2019 — Standard for Floating-Point Arithmetic (integer representation context)
- RFC 4291 — IP Version 6 Addressing Architecture (hexadecimal notation for IPv6)
Understanding numeral systems in computing
Every positional number system uses a base (radix) and assigns each digit a weight based on its position. In decimal (base 10), the rightmost digit is ones, the next is tens, then hundreds. Binary (base 2) uses only 0 and 1, mapping directly to on/off transistor states. Octal (base 8) groups three bits per digit, and hexadecimal (base 16) groups four bits per digit, using A–F for values 10–15. Converting between bases uses repeated division: divide the number by the target radix, record the remainder, repeat with the quotient until zero, then read remainders in reverse order. This algorithm underlies all base conversion in programming.
Practical developer use cases for base conversion
Developers use base conversion when inspecting memory dumps, debugging bitwise operations, interpreting file permissions, and working with color codes. Unix file permissions (e.g. 755) are octal: each digit encodes read/write/execute for owner, group, and others. CSS hex colors like #FF8800 are three concatenated bytes in hexadecimal. IPv6 addresses are written in hex. Bitmasks and flags are often expressed in hex for readability (0xFF for a byte mask, 0xFFFF for 16 bits). When debugging low-level code or network protocols, converting between decimal, hex, and binary quickly reveals the underlying bit patterns.
Base conversion calculator FAQs
Why are binary, octal, and hexadecimal used in computing?
Binary maps directly to the on/off states of transistors, making it the native language of hardware. Octal and hexadecimal are compact shorthand for binary — one hex digit represents exactly four bits and one octal digit represents three bits — so programmers use them to express addresses, bitmasks, and color codes more concisely than long binary strings.
How do I convert in the other direction (e.g., hex to decimal)?
Multiply each digit by its positional power of the base and sum the results. For example, hex 1A3 = 1×16² + 10×16¹ + 3×16⁰ = 256 + 160 + 3 = 419 in decimal.
What happens with very large numbers?
The calculator only accepts values up to JavaScript's safe integer limit: 2^53 − 1 (9,007,199,254,740,991). Larger numbers are rejected because they can lose least-significant digits in the browser.
Can I convert negative numbers or fractions?
This tool handles non-negative whole numbers. Negative integers in computing are typically represented using two's complement in a fixed bit width, and fractional values use IEEE 754 floating-point encoding — both require additional parameters this calculator does not collect.
Why does 0x prefix appear in code but not in the output?
The 0x prefix (and 0b for binary, 0o for octal) is a language-specific literal syntax telling the compiler or interpreter which base to expect. The calculator outputs the raw digit string without a prefix so it can be used in any context.