CipherMatrix

Binary, Decimal, Hexadecimal and Octal Converter

Type a number in any base and see it instantly in binary, octal, decimal and hexadecimal, or in any base from 2 to 36, for integers of any size.

How positional number systems work

In base b, each digit has a place value that is a power of b. The decimal number 175 means 1·10² + 7·10¹ + 5·10⁰. The same value in binary (base 2) is 10101111, which means 1·2⁷ + 0·2⁶ + 1·2⁵ + 0·2⁴ + 1·2³ + 1·2² + 1·2¹ + 1·2⁰. Computers use binary because each digit maps to a two-state circuit, and use octal and hexadecimal as compact ways to write binary.

Converting decimal to another base

Divide the number by the target base, write down the remainder, and repeat with the quotient until it reaches 0. The remainders, read from last to first, are the digits. For 175 in base 2 the remainders are 1, 1, 1, 1, 0, 1, 0, 1 from the first division to the last, giving 10101111 when read in reverse.

Why hexadecimal and octal are convenient

Since 16 = 2⁴, each hexadecimal digit equals exactly four binary digits (a nibble), and two hexadecimal digits make a byte. So 10101111 splits into 1010 and 1111, which is AF in hexadecimal. Octal works the same way with groups of three bits, because 8 = 2³.

Using the converter

Type in any field and the other fields update at once. Prefixes 0b, 0o and 0x are accepted, as are a leading minus sign and spaces. The details panel shows the bit length, the binary and hexadecimal values grouped for easy reading, and how many bytes are needed. The custom-base field handles every base from 2 to 36, using the letters A to Z for digits above 9.

Negative numbers are shown with a minus sign rather than in two's complement, so −5 becomes −101 in binary. Two's complement depends on a chosen word size (8, 16, 32 bits), which is a separate topic in computer architecture. Fractions are not converted here: the tool works with integers only, which keeps every result exact.

Worked examples

These examples are computed by the same engine as the calculator above, so you can compare each step with your own working.

Converting 175 to binary, octal and hexadecimal

Binary
10101111
Octal
257
Hexadecimal
AF

Step-by-step solution

Formula used
value = Σ digit × base^position
  1. CalculateDecimal 175 to binary by repeated division
    Read the remainders from bottom to top: 10101111
    StepDivisionQuotientRemainder (digit)
    0175 ÷ 2871
    187 ÷ 2431
    243 ÷ 2211
    321 ÷ 2101
    410 ÷ 250
    55 ÷ 221
    62 ÷ 210
    71 ÷ 201
  2. CalculateDecimal 175 to octal by repeated division
    Read the remainders from bottom to top: 257
    StepDivisionQuotientRemainder (digit)
    0175 ÷ 8217
    121 ÷ 825
    22 ÷ 802
  3. CalculateDecimal 175 to hexadecimal by repeated division
    Read the remainders from bottom to top: AF
    StepDivisionQuotientRemainder (digit)
    0175 ÷ 1610F
    110 ÷ 160A

Frequently asked questions

How do I convert binary to decimal?

Multiply each bit by the matching power of 2, starting with 2^0 on the right, and add the results. For example, 1011 = 8 + 0 + 2 + 1 = 11.

What does 0x mean?

It is a common prefix marking a hexadecimal number, as in 0xFF = 255. Similarly 0b marks binary and 0o marks octal.

How many bits are in a hexadecimal digit?

Four. This is why two hexadecimal digits describe exactly one byte.

Is there a size limit?

Integers use arbitrary-precision arithmetic, so there is no practical limit apart from a cap on the number of characters you can enter.

Related calculators