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
Equivalents
→ Binary
→ Decimal
Common pairings
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