Decimal Base Converter

Convert fractions such as 0.1 to binary, octal and hex, with repeating digits and every step shown.

 
–
 
Examples
Input base
Convert to
Digits after the point
Custom digits

In other bases

Step by step

How computers store it (IEEE 754)

Floating-point numbers store a binary fraction rounded to a fixed number of bits. Here is how the number you entered is stored, and how far it is from the exact value.

Double precision (64-bit)

Bits (sign | exponent | fraction)–
Hex–
Stored value–
Difference–

Single precision (32-bit)

Bits (sign | exponent | fraction)–
Hex–
Stored value–
Difference–

Why 0.1 + 0.2 is not exactly 0.3

How to Use

1

Enter a number

Type the fraction you want to convert. The page opens with 0.1 already converted to binary. To turn a binary, octal or hex fraction into decimal, change the input base.

2

Choose the base and digits

Pick the base to convert to and how many digits to keep for fractions that never end (8, 16, 23, 32, 52 or any number). The error from cutting off is shown too.

3

Check the answer and the steps

Repeating digits are shown in parentheses. The tables below walk through multiplying the fraction by the base, dividing the whole-number part, and how the value is stored in IEEE 754.

What is the Decimal Base Converter?

A converter for fractions: decimal to binary, octal and hex, and binary, octal or hex fractions back to decimal. Numbers such as 0.1 that binary cannot represent exactly are shown with their repeating digits, such as 0.0(0011), along with the value and error after cutting off at the number of digits you choose. The step-by-step tables make it useful for computer science classes and exams. Calculations use exact fractions and run in your browser.

Features

  • Repeating digitsFractions that never end are written like 0.0(0011), with the repeating part in parentheses.
  • Cut-off and errorKeep 8, 16, 23, 32, 52 or any number of digits and see the difference from the exact value.
  • Step-by-step tablesMultiply-and-take-the-integer steps, division for the whole-number part, and digit weights.
  • IEEE 754 viewSingle and double precision bits, the stored value, and why 0.1 + 0.2 is not 0.3.

Use Cases

  • Practicing base conversion for computer science exams
  • Seeing what 0.1 looks like in binary
  • Understanding floating-point errors such as 0.1 + 0.2
  • Turning hex or octal fractions into decimal
  • Estimating how many bits a fixed-point number needs

Related tools

For whole numbers in binary, octal, decimal and hex, with bit widths and two's complement, use the Number Base Converter. To convert text and character codes, try the ASCII Converter; for Unix time, the Unix Timestamp Converter.

FAQ

What is 0.1 in binary?
0.000110011001100…, with “0011” repeating forever, written 0.0(0011). Binary cannot represent it exactly, so it is cut off at some number of digits. Cut off at 16 digits after the point it is 0.0001100110011001, which differs from 0.1 by about 0.0000092 (9.16 × 10⁻⁶).
Why can’t binary represent some decimals exactly?
0.1 is the fraction 1/10, and 10 = 2 × 5. A fraction ends after a finite number of binary digits only if its reduced denominator is a power of 2. The factor 5 makes 0.1 repeat in binary, just as 1/3 repeats as 0.333… in decimal. Values such as 0.5 (1/2) and 0.75 (3/4) are exact.
How do I convert a binary fraction to decimal?
Multiply each digit after the point by 1/2, 1/4, 1/8 and so on (2⁻¹, 2⁻², 2⁻³…) and add them up: 0.1101 in binary is 0.5 + 0.25 + 0 + 0.0625 = 0.8125. A binary fraction always ends in decimal. Set the input base to binary to see this as a table.
How do hex and octal fractions work?
The same way as binary: multiply the fraction by 16 (or 8) and take the whole-number part, again and again. 0.1 is 0.1999… = 0.1(9) in hex and 0.0(6314) in octal. One hex digit is four binary digits and one octal digit is three, so you can also group binary digits by fours or threes from the point.
How many digits should I keep?
It depends on the use. Floating-point numbers keep 23 fraction bits in single precision and 52 in double precision (plus a hidden leading 1, so 24 and 53 bits of precision). For exam questions, follow the instructions. This tool cuts off at 8, 16, 23, 32, 52 or any number of digits and shows the error.
Why is 0.1 + 0.2 not exactly 0.3?
Both 0.1 and 0.2 repeat in binary, so double precision stores slightly different values (0.1000000000000000055… and 0.2000000000000000111…). Their sum is 0.3000000000000000444…, which does not match the stored value of 0.3 (0.2999999999999999888…), so it prints as 0.30000000000000004. See the IEEE 754 section below.
Can it convert numbers with a whole-number part, such as 12.375?
Yes. The whole-number part is converted by dividing by the base and reading the remainders from the bottom, and the fraction by multiplying, with both steps shown. 12.375 is 1100.011 in binary.
Can it convert negative numbers?
Enter a sign, such as -0.1, and the result keeps the sign. For two's complement with a fixed bit width, use the Number Base Converter.
Is my input saved?
No. Everything is calculated in your browser, and nothing you enter is sent to or stored on a server.