Number Base

Convert between binary, octal, decimal and hex.

Input base
11111111
Binary
377
Octal
255
Decimal
FF
Hexadecimal

How to Use the Number Base Calculator

  1. Enter your number in the input field and select its current base (binary, octal, decimal, or hexadecimal) from the 'From Base' dropdown.
  2. Choose the target base you want to convert to in the 'To Base' dropdown (or view all four representations at once if available).
  3. Click **Convert** — the calculator instantly displays the equivalent value in the selected base(s).
  4. Review the step-by-step breakdown shown below the result to understand each division or multiplication step.
  5. Copy the result directly from the output field to use in your code, exam, or project.

Number Base Conversion Formula

Decimal value = Σ (dᵢ × Bⁱ)  for i = 0 to n−1

where the digits are read right-to-left (position 0 is the rightmost digit).

Decimal → Base B:  repeatedly divide N by B; remainders (read bottom-to-top) give the result.

Every positional numeral system assigns a place value that is a power of the base. To convert a number from base B to decimal (base 10), multiply each digit by B raised to the power of its position (counting from 0 at the rightmost digit) and sum the results. To convert from decimal to base B, repeatedly divide the decimal value by B and collect the remainders in reverse order. For hexadecimal, digits above 9 are represented as A=10, B=11, C=12, D=13, E=14, F=15.

  • dᵢ — The digit at position i in the source-base number (rightmost digit is position 0).
  • B — The source base (e.g., 2 for binary, 8 for octal, 10 for decimal, 16 for hexadecimal).
  • i — The positional index of each digit, starting at 0 for the least-significant (rightmost) digit.
  • n — The total number of digits in the source-base number.
  • N — The decimal (base-10) integer being converted to another base.
  • Σ — Summation — add up all the products dᵢ × Bⁱ across every digit position.

Worked Example: Convert Decimal 255 to Binary, Octal, and Hexadecimal

Source number: 255 (decimal, base 10)
**Decimal → Binary (base 2):**
255 ÷ 2 = 127 remainder 1
127 ÷ 2 = 63  remainder 1
63  ÷ 2 = 31  remainder 1
31  ÷ 2 = 15  remainder 1
15  ÷ 2 = 7   remainder 1
7   ÷ 2 = 3   remainder 1
3   ÷ 2 = 1   remainder 1
1   ÷ 2 = 0   remainder 1
Read remainders bottom-to-top → 11111111

**Decimal → Octal (base 8):**
255 ÷ 8 = 31 remainder 7
31  ÷ 8 = 3  remainder 7
3   ÷ 8 = 0  remainder 3
Read remainders bottom-to-top → 377

**Decimal → Hexadecimal (base 16):**
255 ÷ 16 = 15 remainder 15 → F
15  ÷ 16 = 0  remainder 15 → F
Read remainders bottom-to-top → FF

Result: 255 (decimal) = 11111111 (binary) = 377 (octal) = FF (hexadecimal)

What Your Result Means

The decimal value 255 is a classic example in computing — it equals 2⁸ − 1, meaning all 8 bits in one byte are set to 1, shown clearly by the binary result 11111111. In octal, 377 is frequently used in Unix file permissions. The hexadecimal FF is ubiquitous in web color codes (#FFFFFF = white) and memory address masks. All four representations refer to exactly the same quantity — they simply use different positional bases to express it.

Understanding Number Base

Understanding Number Bases

A numeral base (or radix) defines how many unique digits a positional number system uses before it 'carries over' to the next place. Humans naturally use base 10 (decimal) — ten digits, 0–9. Computers operate on base 2 (binary) — only two states, 0 and 1, matching off/on electrical signals.

The Four Common Bases

| Base | Name | Digits Used | Common Use | |------|-------------|--------------------------|-----------------------------| | 2 | Binary | 0, 1 | CPU logic, bitwise ops | | 8 | Octal | 0–7 | Unix permissions, legacy | | 10 | Decimal | 0–9 | Everyday arithmetic | | 16 | Hexadecimal | 0–9, A–F | Colors, memory addresses |

Why Hexadecimal Is So Useful

One hexadecimal digit represents exactly 4 binary bits (a nibble). Two hex digits represent a full byte (8 bits), making hex a compact and human-readable shorthand for binary data — which is why memory dumps, color codes, and MAC addresses all use it.

Octal and Unix Permissions

Octal encodes 3 binary bits per digit. Unix file permissions are stored as 9 bits (read/write/execute for owner, group, world), so three octal digits perfectly capture them: chmod 755 means 111 101 101 in binary.

Powers of the Base

Every digit in a positional number has a weight equal to the base raised to that digit's position index. For example, binary 1011 = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 in decimal.

Common Mistakes

  • **Confusing the source base**: Entering a hexadecimal number but leaving the 'From Base' set to decimal will produce a completely wrong result. Always specify the correct source base first.
  • **Using invalid digits for the base**: Binary only allows 0 and 1; octal only allows 0–7; decimal allows 0–9. Entering '9' in a binary field or '8' in an octal field is an error.
  • **Forgetting hex letter case**: Hexadecimal digits A–F are case-insensitive mathematically, but some systems expect uppercase or lowercase specifically. The calculator outputs uppercase by convention.
  • **Assuming leading zeros matter**: Leading zeros (e.g., 0011 vs 11 in binary) do not change the value, but they do matter when representing fixed-width data types like bytes or nibbles.
  • **Mixing up octal and decimal for small numbers**: The numbers 0–7 look identical in decimal and octal, but 8 and 9 do not exist in octal — a common source of off-by-one errors in programming.

Common Questions About Number Base

What is 1024 in hexadecimal?

1024 in decimal equals 400 in hexadecimal. Calculation: 1024 ÷ 16 = 64 remainder 0; 64 ÷ 16 = 4 remainder 0; 4 ÷ 16 = 0 remainder 4. Reading remainders bottom-to-top: 400.

What is the hexadecimal color code system?

Web colors are expressed as six hex digits (#RRGGBB), where each pair represents a byte (0–255) for red, green, and blue intensity. For example, #FF5733 has red=255, green=87, blue=51.

How are Unix file permissions related to octal numbers?

Unix permissions are three groups of three bits (read=4, write=2, execute=1). Each group is summed to a single octal digit, giving codes like 755 (owner: rwx=7, group: r-x=5, others: r-x=5).

What is two's complement and why is it used?

Two's complement is the standard way to represent signed (positive and negative) integers in binary. To negate a number, invert all bits and add 1. It simplifies CPU addition circuits because positive and negative numbers can be added with the same hardware.

How do I convert between octal and binary directly?

Each octal digit maps to exactly 3 binary bits. Replace every octal digit with its 3-bit binary equivalent. For example, octal 57 = 5→101, 7→111, so the binary result is 101111.

Frequently Asked Questions

What is the difference between binary, octal, decimal, and hexadecimal?

They are all positional numeral systems that express the same quantities using different bases: binary uses base 2 (digits 0–1), octal uses base 8 (digits 0–7), decimal uses base 10 (digits 0–9), and hexadecimal uses base 16 (digits 0–9 and A–F). The underlying value is identical — only the notation differs.

How do I convert binary to decimal manually?

Write down the binary number, then multiply each digit by 2 raised to its position (starting at 0 from the right) and sum all the products. For example, 1101 = 1×8 + 1×4 + 0×2 + 1×1 = 13 in decimal.

What does '0x' mean before a number?

'0x' is a prefix used in programming languages like C, Python, and JavaScript to indicate that the following number is in hexadecimal (base 16). For example, 0xFF means FF in hex, which equals 255 in decimal.

Why do computers use binary instead of decimal?

Electronic circuits are most reliably built with two states — voltage present (1) or absent (0). Binary maps perfectly onto these two states, making it the natural language of digital hardware.

Can this calculator handle negative numbers or fractions?

This calculator is designed for non-negative integers. Negative numbers in binary use representations like two's complement, and fractional bases require radix-point arithmetic — these are advanced topics beyond standard base conversion for whole numbers.

How many hexadecimal digits are in one byte?

Exactly two hexadecimal digits represent one byte (8 bits), since each hex digit encodes 4 bits (log₂16 = 4). That's why byte values range from 00 to FF in hex (0 to 255 in decimal).

Related Calculators

Sources

Only sources that have been reviewed are shown. Unverified citations are never published.

Spotted a calculation error?Report an Error