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 value | 42 |
|---|---|
| Binary (base 2) | 101010 |
| Hexadecimal (base 16) | 2A |
| Octal (base 8) | 52 |
Number Base Converter: formula
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
| Decimal value | Binary (base 2) | Hexadecimal (base 16) | Octal (base 8) |
|---|---|---|---|
| 34 | 100010 | 22 | 42 |
| 38 | 100110 | 26 | 46 |
| 42 (example) | 101010 | 2A | 52 |
| 46 | 101110 | 2E | 56 |
| 50 | 110010 | 32 | 62 |
Number Base Converter: individual input comparisons
| Input | Value | Binary (base 2) | Hexadecimal (base 16) | Octal (base 8) |
|---|---|---|---|---|
| Decimal value | 34 | 100010 | 22 | 42 |
| 38 | 100110 | 26 | 46 | |
| 42 | 101010 | 2A | 52 | |
| 46 | 101110 | 2E | 56 | |
| 50 | 110010 | 32 | 62 |
Number Base Converter: values and definitions
| Quantity and definition | Value 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.