Introduction
Computers can produce exact answers for some numbers and only approximate others. This difference comes down to how numbers are represented inside machines, the nature of certain mathematical quantities, and trade-offs between precision, speed, and memory. This article explains why exactness matters, when it is possible, and what techniques programmers and mathematicians use to get exact or sufficiently accurate results.
- What do we mean by “exact” and “approximate”?
- How computers represent numbers
- Why some numbers are exactly representable and others are not
- Examples that show the difference
- How arithmetic operations introduce or amplify error
- Mathematical limits: computable numbers vs. uncomputable numbers
- Techniques for exact computation
- When approximations are acceptable—and how to manage them
- Practical consequences and common surprises
- Historical and practical context
- Choosing the right approach
- Summary: why some numbers are exact and others are not
- Conclusion
What do we mean by “exact” and “approximate”?
When we say a computer calculates a number exactly, we mean the machine’s representation and operations give a result that matches the true mathematical value with no rounding error. In practice, exactness implies that the stored value is a perfect representation of the intended number and arithmetic operations preserve that perfection.
Approximate means the representation or the result only comes close to the true value. Error can arise immediately when a number is stored, or later during arithmetic when results are rounded to fit the machine’s format. Approximation is not wrong in the casual sense; often it is close enough for a task. But it is not mathematically identical to the true number.
How computers represent numbers
Computers store data using bits—binary digits 0 and 1. To represent numbers, hardware and software use established formats that map sequences of bits to numerical values. The two common families are integer representation and floating-point representation.
Integers: exact within limits
Integers are whole numbers: … -2, -1, 0, 1, 2, … Computers represent integers in binary using a fixed number of bits. A 32-bit signed integer can represent values from -2,147,483,648 to 2,147,483,647 exactly. Within that range, arithmetic on integers (addition, subtraction, multiplication with care) produces exact results because every representable integer corresponds to a unique bit pattern.
However, there’s a limit: if a calculation produces a value outside the representable range, an overflow occurs and the result is incorrect or triggers an error. So integers are exact only up to the machine’s range.
Floating-point numbers: approximate but versatile
Floating-point formats, standardized by IEEE 754, represent a wide range of real numbers using three parts: a sign bit, an exponent, and a significand or mantissa. For example, IEEE double precision uses 64 bits: 1 for sign, 11 for exponent, 52 for the significand. This lets computers represent both very large and very small numbers but with limited precision—about 15–17 decimal digits for doubles.
Floating-point numbers approximate most real numbers because only numbers that fit the finite binary format are exact. For instance, 0.5 is exact in binary, but 0.1 (one-tenth) is a repeating binary fraction and cannot be represented exactly. As a result, simple arithmetic like 0.1 + 0.2 may produce 0.30000000000000004 in floating-point, which is an approximation error, not a bug in the code.
Why some numbers are exactly representable and others are not
Exact representability depends on how a number looks in binary (base 2) when using binary-based storage formats. A rational number is a fraction p/q where p and q are integers. In base 10, 1/2 = 0.5 and 1/5 = 0.2 are finite decimals; in base 2, 1/2 is finite (0.1) but 1/5 is repeating.
The key rule: in binary floating-point, a rational number p/q has a finite binary expansion exactly when q is a power of 2 after the fraction is in lowest terms. For example:
1/2 = 0.1 (binary) → exact
3/8 = 0.011 (binary) → exact
1/3 = 0.010101… (binary) → repeating → cannot be stored exactly
0.1 (decimal) = 1/10 = 1/(2*5) → denominator contains a factor 5 → repeating in binary → not exact in base 2
Examples that show the difference
Example: integers. If your program sets x = 42 using a standard 32-bit integer, x is exactly 42. Adding 1 to x produces exactly 43 until you reach the maximum representable integer.
Example: simple decimal fractions. In binary floating-point, 0.5 is exact but 0.25 is exact and 0.75 is exact because their denominators are powers of two. But 0.1 is not exact, so repeated arithmetic or comparisons can produce surprising results.
Example: irrational numbers. Numbers like pi (π) and the square root of 2 are irrational: they have infinite, non-repeating decimal expansions. No finite binary or decimal representation can store them exactly. Computers store approximations, typically rounded to the available precision (for π, many programs use the best double-precision approximation available).
How arithmetic operations introduce or amplify error
Even when inputs are exactly representable, arithmetic operations can introduce rounding error because results may require more digits than the format can hold. For example, adding two very close large floating-point numbers can cause loss of significance: the small difference may vanish if it falls beyond the machine’s precision.
Multiplication and division similarly produce results that might need rounding. Repeated operations can accumulate rounding errors. Numerical analysts study these effects and design algorithms that minimize error growth for important tasks such as solving linear systems, computing eigenvalues, or integrating functions.
Mathematical limits: computable numbers vs. uncomputable numbers
Beyond representability, there is a deeper mathematical notion: computability. A computable number is one for which there exists an algorithm that can produce its digits to any desired accuracy in a finite amount of time. Popular constants like π and e are computable: algorithms can generate arbitrarily many exact digits. Computers still store only finite approximations, but we can make that approximation as accurate as we need (limited by time and memory).
Most real numbers are not computable—indeed, the set of computable numbers is countable while the real numbers are uncountable. Non-computable numbers cannot be generated digit by digit by any algorithm. These are mathematical constructions rather than everyday numbers, and they are beyond what computers can produce exactly or even arbitrarily well.
Techniques for exact computation
When exactness matters, software and mathematicians use special representations and methods.
Arbitrary-precision integers (big integers): Libraries such as GMP or BigInt types in many languages let programs store integers with as many digits as memory allows, avoiding overflow and preserving exactness for integer arithmetic.
Rational numbers: A rational number can be stored as an exact fraction p/q using integer numerator and denominator. Arithmetic keeps results exact by updating p and q and, when useful, reducing by the greatest common divisor. This is practical when denominators remain small but can become slow and memory-intensive if numbers grow.
Arbitrary-precision floating-point: Libraries provide floating-point types with user-controlled precision. These allow accurate approximations of irrational numbers to many digits but still remain approximations because the representation is finite.
Symbolic computation: Systems like Mathematica, Maple, and SymPy can manipulate exact symbols rather than numeric approximations. They can simplify algebraic expressions, compute exact roots in closed form when possible, and represent numbers symbolically (for example, as sqrt(2) or pi). Symbolic methods are powerful but can be computationally expensive or impossible for general problems.
When approximations are acceptable—and how to manage them
Most real-world computing relies on approximations because they are fast and require less memory. Engineers and scientists accept finite precision but manage error carefully.
Strategies include choosing a data type with sufficient precision (double vs. single precision), using algorithms that are numerically stable (they don’t amplify error), scaling and preconditioning to avoid overflow/underflow, and using interval arithmetic to track bounds on error.
Testing and verification are important: compare results at different precisions, include checks that detect loss of significance, and use exact methods for critical verifications—e.g., validating an approximate result with rational arithmetic for a small instance.
Practical consequences and common surprises
Floating-point rounding causes everyday surprises in programming: comparing floats for equality is dangerous because two computations that should be mathematically equal may differ in low-order bits. The common fix is to test whether the difference is smaller than a tolerance suited to the application.
Financial applications often avoid binary floating-point because decimal fractions like 0.01 (one cent) are not exact in binary. Instead, fixed-point arithmetic or decimal floating-point formats are used to represent currency exactly to a chosen number of decimal places.
Scientific computing emphasizes reproducibility and accuracy. Libraries and standards exist to ensure that critical functions (trigonometric, exponential) meet error bounds. Still, users must be aware that some algorithms produce accumulated error over many iterations.
Historical and practical context
Early computers used a variety of numeric formats. The IEEE 754 standard, introduced in 1985, unified floating-point behavior across platforms and defined rounding rules, special values (NaN, infinities), and exceptions. This standard makes floating-point results predictable and portable but does not eliminate the fundamental limitation that binary floating-point cannot exactly represent most real numbers.
Modern programming languages and platforms often provide high-level abstractions—big integers, decimal types, arbitrary-precision floats, and symbolic libraries—so developers can choose exact or high-precision tools when the problem requires it. The choice involves trade-offs in performance, memory, and complexity.
Choosing the right approach
Decide what “exact” means for your problem: exact integer arithmetic, exact rational results, or sufficiently accurate real-number approximations. For counting, indexing, or cryptography, exact integers are essential. For money, fixed-point or decimal arithmetic avoids binary rounding errors. For scientific simulations, controlled floating-point precision and stable algorithms are usually best.
When exact algebraic relationships matter, consider symbolic computation. When you need many correct digits of an irrational constant or a high-precision result, use arbitrary-precision libraries. For routine calculations where speed matters and a small error is tolerable, standard double precision is often adequate.
Summary: why some numbers are exact and others are not
In short, exactness depends on representation and mathematics. Integers within a machine’s limits are exact because bit patterns map directly to whole numbers. Binary floating-point can represent only numbers with finite binary expansions exactly; most rational fractions and all irrationals require infinite expansions and are therefore approximated. Computability theory adds that some numbers cannot even be generated digit-by-digit by any algorithm. Practical computing offers many tools—big integers, rationals, arbitrary precision, symbolic math—to achieve exactness when needed, at the cost of speed and memory.
Conclusion
Computers calculate some numbers exactly because those numbers fit the machine’s finite representation; others cannot be exact because of base mismatch, infinite expansions, or fundamental computability limits. Understanding numeric representation, error sources, and available exact or high-precision techniques helps you choose the right approach for accuracy, performance, and reliability.

