NUMBER SYSTEMS

Base Converter●

One number. Four ways to write it. See how each conversion works.

Whole numbers only. Use a leading minus for negatives. Matching 0b, 0o and 0x prefixes are optional.

Exact integer conversion · up to 4096 bits

The same number in four bases

BinaryBase 2

101010

OctalBase 8

52

DecimalBase 10

42

HexadecimalBase 16

2A

Follow the conversion.

Read the place values

Read positions from right to left, starting at power 0. A–F have values 10–15.

4 × 10¹ + 2 × 10⁰ = 42

Build the new representation

Divide the magnitude repeatedly. Read the remainders from bottom to top.

    Your numbers, answers and scores stay in this tab. They are not uploaded or saved.

    Different bases. The same place-value idea.

    Allowed digits and base values
    BaseValueAllowed digits
    Binary20–1
    Octal80–7
    Decimal100–9
    Hexadecimal160–9, A–F

    Start counting positions at zero

    In binary, 1010 = 1 × 2³ + 0 × 2² + 1 × 2¹ + 0 × 2⁰ = 10 in decimal.

    Letters are digits too

    In hexadecimal, A = 10 through F = 15. FF is 15 × 16 + 15 = 255 in decimal.

    Keep the sign

    −42 in decimal becomes −101010 in binary. This tool does not assume a bit width or encode two’s complement.

    A base changes the notation, not the number.

    Each position represents a power of its base. Binary uses powers of 2; octal uses 8; decimal uses 10; hexadecimal uses 16. Leading zeros do not change the value. Hex letters are case-insensitive.

    About exact integer representation ↗

    Common questions

    Will large numbers lose precision?

    Conversions use integer arithmetic without rounding. Magnitudes up to 4096 bits are supported. Results are exact even beyond the safe range of ordinary JavaScript numbers.

    Can I use prefixes such as 0xFF?

    Yes. With hexadecimal selected, 0xFF is accepted; binary accepts 0b and octal accepts 0o. A prefix does not switch the selected base. Uppercase and lowercase letters both work.

    What about negative numbers and two’s complement?

    A minus sign is preserved in every base. This tool converts signed mathematical integers, not fixed-width machine representations. For example, −1 remains −1 rather than becoming a string of 1 bits.

    Are fractions or scientific notation supported?

    This version accepts whole numbers only. Decimal fractions, digit separators and scientific notation are not accepted. In hex, E is a digit, so 1E3 means 483 in decimal.

    Do the practice questions repeat?

    Each set contains ten distinct numerical values. New sets are generated randomly, so numbers can repeat between sets. No answer history or scores are saved.