terican

BIPM-ratified constants · v1.0

Converter

Binary, fraction calculator.

Convert binary fractions to decimal or decimal numbers to binary fractions with configurable fractional bit precision for non-terminating results.

From

decimal

decimal_to_binary

13.625 decimal_to_binary =1,101Converted Value

Equivalents

Precision: 6 dp · Notation: Decimal · 2 units

→ Binary

Decimaldecimal_to_binary1,101

→ Decimal

Binarybinary_to_decimal

Common pairings

1 decimal_to_binaryequals1 binary_to_decimal
1 binary_to_decimalequals1 decimal_to_binary

The conversion

How the value
is computed.

Binary Fraction Conversion: Formula and Methodology

A binary fraction represents a real number in base-2 positional notation, using a binary point to separate the integer part from the fractional part. Every digital computing system stores and processes numbers in binary form, making binary fraction conversion a foundational skill in computer science, electronics engineering, and digital signal processing. Understanding the underlying formula reveals why seemingly simple decimal values such as 0.1 can cause subtle precision errors in software, and how all microprocessors and arithmetic units perform calculations at the fundamental level.

The Core Positional-Value Formula

The formula for converting a binary fraction to its decimal equivalent is:

N10 = ∑i=0n−1 bi · 2i + ∑j=1m b−j · 2−j

Where:

  • bi is the binary digit (0 or 1) at position i to the left of the binary point, contributing to the integer part of the number.
  • b−j is the binary digit at position j to the right of the binary point, contributing to the fractional part.
  • n is the total number of integer bits (digits left of the binary point).
  • m is the total number of fractional bits (digits right of the binary point).

Each bit position carries a power-of-two weight. Integer positions carry weights 20=1, 21=2, 22=4, 23=8, increasing by a factor of two moving left. Fractional positions carry weights 2−1=0.5, 2−2=0.25, 2−3=0.125, decreasing by half moving right. This positional-weight principle is covered in Khan Academy's AP Computer Science Principles: Binary Numbers curriculum.

Converting a Binary Fraction to Decimal

To convert the binary fraction 1101.1012 to decimal, multiply each bit by its positional weight and sum all products:

  • Integer part: 1×23 + 1×22 + 0×21 + 1×20 = 8 + 4 + 0 + 1 = 13
  • Fractional part: 1×2−1 + 0×2−2 + 1×2−3 = 0.5 + 0 + 0.125 = 0.625
  • Final result: 13 + 0.625 = 13.62510

Converting a Decimal Number to Binary Fraction

Decimal-to-binary conversion handles the integer and fractional parts with two separate algorithms that are then combined.

Integer part — repeated division by 2: Divide the integer repeatedly by 2 and record each remainder. For the value 13: 13÷2=6 R1, 6÷2=3 R0, 3÷2=1 R1, 1÷2=0 R1. Reading remainders from bottom to top yields 11012.

Fractional part — repeated multiplication by 2: Multiply the fraction repeatedly by 2 and extract the integer part of each product. For 0.625: 0.625×2=1.25, 0.25×2=0.5, 0.5×2=1.0. Reading extracted integers top to bottom gives .1012. The combined result is 1101.1012, confirming the earlier example.

Non-Terminating Binary Fractions and Precision

A decimal fraction terminates in binary only when its denominator in lowest terms is a pure power of 2. Because 0.1 = 1/10 and 10 = 2×5, the prime factor 5 prevents termination, producing the repeating binary sequence 0.0001100110011… The Fractional Bit Precision setting truncates such values to a user-specified bit count. With 4 bits, 0.1 approximates to 0.00012 = 0.062510 (error ≈ 37.5%). With 16 bits, the error drops below 0.002%. As documented in the GNU Emacs Calc 2.02 Manual — Data Types and Number Bases, scientific computing tools explicitly expose this truncation behavior during cross-base conversions, mirroring the behavior of hardware floating-point units.

Practical Applications

  • IEEE 754 floating-point: Single-precision floats store a 23-bit binary fraction (significand), delivering 7–8 significant decimal digits. Double-precision uses 52 fractional bits for 15–17 digits.
  • Digital signal processing: Fixed-point DSP chips represent audio samples and sensor readings as Q-format binary fractions, where the binary point position is fixed by hardware convention.
  • Embedded systems: Microcontrollers without hardware floating-point units (FPUs) perform efficient arithmetic using fixed-point binary fraction representations to save computational resources.
  • Networking: IPv4 subnet masks and CIDR prefix calculations rely on binary fraction interpretation during bitwise address operations and network address aggregation.

Reference

Frequently asked questions

What is a binary fraction and how does it differ from a decimal fraction?
A binary fraction uses base-2 positional notation where each digit to the right of the binary point represents a successively smaller negative power of 2: one-half (0.5), one-quarter (0.25), one-eighth (0.125), and so on. A decimal fraction uses base-10 positional notation (tenths, hundredths, thousandths). The critical practical difference is that fractions whose denominators contain prime factors other than 2 — such as 5 or 10 — terminate in decimal but produce infinitely repeating sequences in binary, causing representation errors in all base-2 digital computing hardware.
How do you convert the decimal number 0.1 to binary?
Converting 0.1 to binary requires repeated multiplication by 2, collecting the integer part of each product: 0.1x2=0.2 (bit 0), 0.2x2=0.4 (bit 0), 0.4x2=0.8 (bit 0), 0.8x2=1.6 (bit 1), 0.6x2=1.2 (bit 1), then the cycle repeats. The result is the non-terminating binary fraction 0.0001100110011... This non-termination explains why floating-point arithmetic in languages like Python, JavaScript, and C produces small rounding errors when computing with values like 0.1 or 0.3.
Why do some decimal fractions not terminate in binary?
A decimal fraction terminates in binary only if its denominator, expressed in lowest terms, is a power of 2 (1, 2, 4, 8, 16, etc.). For example, 0.625 = 5/8 = 5/2^3, so it terminates exactly as 0.101 in binary. However, 0.1 = 1/10 and 10 = 2 x 5; because the denominator contains the prime factor 5, which is not a power of 2, the binary representation repeats infinitely. This is a fundamental mathematical property of positional numeral systems, not a limitation of any specific calculator or computer.
What does the Fractional Bit Precision setting do, and how many bits should be used?
Fractional Bit Precision sets the maximum number of binary digits output after the binary point during decimal-to-binary conversion. Terminating fractions such as 0.625 are always exact regardless of this setting. For non-terminating fractions like 0.1, more bits produce a closer approximation: 8 bits gives 0.00011001 (approximately 0.09765625, error about 2.3%), while 32 bits reduces the absolute error to below 0.00000003%. General-purpose calculations work well with 8 to 16 bits; IEEE 754 double precision uses 52 bits for maximum accuracy in scientific applications.
How are binary fractions used in IEEE 754 floating-point numbers?
IEEE 754 floating-point numbers store real values in the form: (-1)^sign x 1.fraction x 2^(exponent - bias). The fraction field is a binary fraction with 23 bits in single precision (float), providing roughly 7 significant decimal digits of precision, and 52 bits in double precision (double), providing about 15 to 17 significant decimal digits. Understanding binary fraction representation directly explains why computing 0.1 + 0.2 in most programming languages returns 0.30000000000000004 rather than exactly 0.3.
Can the binary fraction converter handle negative numbers?
The binary fraction converter processes non-negative values in both conversion directions. Negative binary fractions exist in hardware using sign-magnitude, one's complement, or two's complement notation. In sign-magnitude form, negative 0.625 is represented as -0.101 in binary. Two's complement, the dominant format in modern processors, extends naturally to fixed-point binary fractions by assigning a negative weight to the most significant bit. To convert a negative decimal value, apply the converter to its absolute value and then encode the sign using the target hardware notation.