Number Base Converter Calculator

Computers store everything in binary, and hexadecimal and octal are shorthand because each hex digit represents four bits and each octal digit three. 42 is 101010 in binary, 2A in hexadecimal and 52 in octal. Use it to read color codes, memory addresses, file permissions and network masks.

To check a conversion by hand, add the place values: 32 plus 8 plus 2 gives 42.

Number Base Converter Calculator: inputs

Calculated result
Binary (base 2)101010
Hexadecimal (base 16)2A
Octal (base 8)52

Decimal value and binary (base 2)

Number Base Converter Calculator: Decimal value and Binary (base 2)5 calculations vary the “Decimal value” input while holding the other entered inputs constant.3410001038100110421010104610111050110010

Enter a non-negative whole number in decimal. The tool shows the same number in binary, hexadecimal and octal. Binary uses digits 0 and 1, octal uses 0 to 7, and hexadecimal uses 0 to 9 and A to F, where A is 10 and F is 15.

Decimals with fractions are not converted, so round or split the integer part first. Very large numbers may exceed the display.

Binary (base 2) from decimal value

Decimal value42
Binary (base 2)101010
Hexadecimal (base 16)2A
Octal (base 8)52

Number Base Converter: formula

The same non-negative integer, displayed in base 2, base 16 and base 8

Base: Wolfram MathWorld

Common error: Assuming a leading zero or a specific digit count signals the base. Programming languages use their own prefix conventions (0x for hex, 0b for binary) precisely because the digits alone don't disambiguate; strip any such prefix before entering a value here.

Negative numbers use two's complement in computers, which the converter does not show. Fractional values convert differently and may not terminate. Letter case in hexadecimal is not significant, but prefixes such as 0x for hex and 0b for binary depend on the language.

Leading zeros do not change the value.

Number Base Converter: changing Decimal value

Binary (base 2): assumed Decimal value scenarios.
Decimal valueBinary (base 2)Hexadecimal (base 16)Octal (base 8)
341000102242
381001102646
42 (example)1010102A52
461011102E56
501100103262

Number Base Converter: individual input comparisons

Number Base Converter Calculator: change one input at a time; other values remain at the stated example.
InputValueBinary (base 2)Hexadecimal (base 16)Octal (base 8)
Decimal value341000102242
381001102646
421010102A52
461011102E56
501100103262

Number Base Converter: values and definitions

Worked-example inputs and the results they produce for the Number Base Converter Calculator.
Quantity and definitionValue used
Decimal value — A non-negative whole number. Any fractional or negative part is dropped before conversion.42
Binary (base 2)101010
Hexadecimal (base 16)2A
Octal (base 8)52

Check the same value in three positional systems

For an assumed decimal input of 42, binary is 101010, octal is 52 and hexadecimal is 2A. Binary expands as 32 + 8 + 2; octal expands as 5 × 8 + 2; hexadecimal expands as 2 × 16 + 10. Each expression reaches the same value.

One hexadecimal digit corresponds to four binary positions, so 2A can also be grouped as 0010 1010. Leading zeroes do not alter that unsigned value. A bit pattern interpreted as a signed computer integer additionally needs its width and representation convention; that is a different question from converting the positive magnitude.

A computer stores every value in binary regardless of which base a person reads it in: hexadecimal exists specifically because four binary digits map onto exactly one hex digit, making a 32-bit value readable as 8 hex characters instead of 32 ones and zeros, which is why memory addresses, color codes and error codes are conventionally shown in hex rather than binary or decimal.

Confirm which base a value you copied from elsewhere is in before typing it here; a value like 100 means something completely different as decimal, binary or hex, and this calculator always reads its input as decimal.

See subnet and networking tools in the networking category, and the modulo calculator for remainders that underlie base conversion. The scientific notation and exponent pages relate to powers of the base. The prime factorization calculator shows another way to decompose numbers.

Why do computers use binary?

Electronic circuits have two stable states, on and off, so binary matches the hardware and makes reliable storage and calculation possible.

What does hexadecimal represent?

A compact way to write binary, where each hex digit stands for four bits, so 2A is 0010 1010.

How do I convert decimal to binary by hand?

Divide by 2 repeatedly and write the remainders from last to first. Dividing 42 this way gives 101010, which you can check by adding place values.