How Computers Represent Fractional Numbers: The Floating-Point Standard

Integers cannot represent fractional values or the enormous range of magnitudes scientific and financial computing requires. This article explains how floating-point numbers encode a sign, exponent, and fraction into a fixed number of bits following the IEEE 754 standard, and covers the precision tradeoffs and rounding issues that come with representing real numbers this way.

Floating PointIEEE 754 StandardPrecision and Rounding

~3 min read · Updated Sep 6, 2026

Why Integers Are Not Enough

All arithmetic covered earlier in this series assumed whole numbers stored as fixed-width binary integers. Many real-world computations, however, require fractional values and numbers spanning an enormous range of magnitudes — from the mass of an electron to the distance between galaxies — which a plain integer representation cannot handle efficiently.

The Core Idea: Scientific Notation in Binary

Floating Point representation borrows the idea behind decimal scientific notation, where a number is expressed as a value multiplied by a power of a base. In binary floating point, a number is broken into three components packed into a fixed-width word:

  • Sign: a single bit indicating whether the number is positive or negative.
  • Exponent: determines the overall magnitude, effectively how far the binary point is shifted.
  • Fraction (also called the Mantissa): holds the significant digits of the number.

Conceptually, a floating-point value is interpreted as:

Value = (−1)^Sign × (1.Fraction) × 2^(Exponent − Bias)

The IEEE 754 Standard

Nearly all modern hardware, including RISC-V, follows the IEEE 754 standard for floating-point representation, which precisely defines the bit widths and behavior of these fields so that floating-point results are consistent across different processors and manufacturers.

  • Single Precision uses 32 bits total: 1 sign bit, 8 exponent bits, and 23 fraction bits.
  • Double Precision uses 64 bits total: 1 sign bit, 11 exponent bits, and 52 fraction bits, providing a much wider range and greater precision at the cost of double the storage.

The standard also uses a Bias value subtracted from the stored exponent field, which allows both very large and very small magnitudes to be represented without needing a separate sign bit for the exponent itself.

Precision Limits and Rounding

Because only a fixed number of fraction bits are available, most real numbers cannot be represented exactly and must be rounded to the nearest representable value. This has a direct practical consequence: floating-point arithmetic does not always behave like exact mathematics.

Example of a common rounding artifact:
0.1 + 0.2 does not always equal exactly 0.3
in floating-point representation, due to rounding
during binary encoding.

This is not a hardware defect but an inherent consequence of representing an infinite range of real numbers using a finite number of bits.

Special Values Defined by the Standard

IEEE 754 reserves specific bit patterns for values that do not correspond to ordinary numbers, including Positive and Negative Infinity, used to represent overflow, and NaN (Not a Number), used to represent the result of undefined operations such as zero divided by zero.

Why Understanding This Matters

Any programmer working with monetary calculations, scientific simulations, or graphics needs to understand that floating-point values carry inherent rounding error, and that comparing two floating-point numbers for exact equality is often unreliable — a direct consequence of the finite-bit representation described in this article.

Written & researched by Dr. Shahin Siami

Related Articles

Cache Fundamentals: How Small, Fast Memory Predicts What You Need Next

A cache works because programs tend to access the same or nearby data repeatedly rather than randomly. This article explains the principle of locality that makes caching effective, how a direct-mapped cache locates data using an address, and what happens on a cache hit versus a cache miss.

Continue

The Memory Hierarchy: Why Computers Use Several Kinds of Memory

No single memory technology is simultaneously fast, large, and cheap. This article introduces the concept of a memory hierarchy that combines several different memory technologies to approximate the speed of the fastest one at the cost of the cheapest, then walks through the core technologies that make up each level.

Continue

Common Misconceptions About Processor Design and Chapter Four's Big Picture

After covering datapaths, pipelining, hazards, and real-world processor comparisons, it is time to correct a handful of persistent misconceptions about how processors actually behave. This article addresses common fallacies about pipelining and performance, then ties together the full journey from simple datapaths to superscalar execution covered throughout this chapter.

Continue

Real-World Pipelines: Comparing ARM and Intel, and Speeding Up Matrix Multiply

Theoretical pipeline concepts take concrete shape in real commercial processors, which vary widely in pipeline depth and issue width depending on their design goals. This article compares how the ARM Cortex-A53 and Intel Core i7 implement pipelining differently for power efficiency versus raw performance, then shows how instruction-level parallelism accelerates matrix multiplication in practice.

Continue

Instruction-Level Parallelism: Executing More Than One Instruction at Once

A single pipeline can only advance one instruction into each stage per cycle, which caps its performance at roughly one instruction per clock. This article explains how processors go beyond that limit by issuing multiple instructions simultaneously, the hardware duplication this requires, and the fundamental limits imposed by dependencies between instructions.

Continue

How a Pipelined Processor Handles Exceptions

Not every instruction executes as expected — some trigger error conditions like an undefined opcode or an arithmetic overflow that the processor must respond to safely. This article explains what exceptions are, how a pipelined processor detects and handles them without corrupting program state, and why exceptions are treated similarly to control hazards.

Continue