Real numbers are essential for representing continuous quantities in computing. They include both rational and irrational numbers and are used in calculations involving measurements and real-world data.
What are real numbers?
Real numbers form one of the most fundamental sets in mathematics. They include all numbers that can be located on a number line, covering both rational and irrational values. This means any number that can be thought of as a point on a continuous line with no gaps falls into the category of real numbers.
A real number can be:
A rational number: any number that can be written as the quotient of two integers (for example, 5, -3, 1/2, or 2.75).
An irrational number: a number that cannot be written as a fraction, and which has a non-terminating, non-repeating decimal expansion (for example, √2, π, or e).
By definition:
ℝ = ℚ ∪ Irrational numbers
In simpler terms, the set of real numbers (ℝ) includes all values from the rational numbers (ℚ) and irrational numbers combined.
Real number notation
The standard notation for the set of real numbers is the symbol:
ℝ
This symbol is commonly used in mathematics and computing to denote that a value, variable, or result belongs to the set of real numbers.
Practice Questions
FAQ
Computers use binary (base-2) rather than decimal (base-10) to store and process data. Many decimal fractions that are simple in base-10, such as 0.1 or 0.2, do not have an exact binary equivalent. This is similar to how one-third cannot be exactly represented in decimal—it results in a repeating value (0.333...). In binary, 0.1 becomes an infinitely repeating sequence, which cannot be stored exactly in a finite number of bits. As a result, computers must round or truncate these representations, introducing small errors known as floating-point approximation errors. This limitation arises from how floating-point numbers are stored using a fixed number of bits for the significand and exponent. For example, IEEE 754 double-precision format uses 64 bits, which provides good but not perfect accuracy. Consequently, even basic arithmetic involving real numbers can produce unexpected results due to these rounding effects, especially in cumulative calculations or comparisons.
Real numbers in computing are usually represented using floating-point formats, which provide a wide dynamic range and can handle both very large and very small numbers. They store numbers in scientific notation with a fractional significand and an exponent. In contrast, fixed-point representation allocates a fixed number of bits to the integer and fractional parts, offering more predictable precision but a smaller dynamic range. Fixed-point numbers are often used in embedded systems, audio processing, or digital signal processing where performance, speed, and resource limitations matter more than range. Floating-point numbers are favoured when greater flexibility and range are required, such as in simulations, 3D graphics, and scientific computation. The choice depends on the trade-off between precision, performance, and the need for dynamic scaling. Floating-point allows for a broader range but less predictability in rounding, while fixed-point is faster and more consistent but limited in scale and prone to overflow.
Machine epsilon is the smallest positive number that, when added to 1.0, results in a distinguishable number greater than 1.0 in a computer system. It represents the upper bound on the relative error due to rounding in floating-point arithmetic. For example, in double-precision (64-bit) floating-point systems, machine epsilon is approximately 2.22 × 10^-16. It is crucial because it defines the precision limit of the system’s real number representation. Understanding machine epsilon helps programmers recognise when numerical results are trustworthy and when tiny differences are likely artefacts of rounding rather than meaningful distinctions. It is especially important in scientific computing, numerical methods, and iterative calculations where floating-point operations are chained. By using machine epsilon in comparisons, programmers can design algorithms that avoid false assumptions of equality and instead check whether two real numbers are “close enough” to be considered equal, accounting for the expected limits of precision on that system.
Denormalised numbers (also called subnormal numbers) are floating-point values that fill the gap between the smallest positive normal number and zero. In the IEEE 754 standard, normalised floating-point numbers require a leading 1 in the significand. However, for very small real numbers near zero, this format cannot represent the values accurately due to underflow. To handle this, denormalised numbers allow a leading 0 in the significand, effectively shifting the exponent lower than the normal minimum. This provides a gradual, rather than abrupt, underflow to zero and allows computers to handle extremely small real values more gracefully. Denormalised numbers are important for ensuring that calculations involving very small quantities—such as probabilities, quantum physics, or precise measurements—remain as accurate as possible without being rounded directly to zero. However, they are slower to process and may result in performance penalties on some hardware, so they are used only when necessary to maintain numerical stability.
Floating-point division involving very large or very small real numbers can lead to special behaviours due to the limitations of precision and range. When dividing by a very small number, the result may exceed the maximum representable value, causing overflow and resulting in infinity. Conversely, dividing very small numbers can lead to underflow, where the result becomes too close to zero to represent accurately, possibly being rounded to zero or represented as a denormalised number. Precision can also suffer significantly, especially if subtracting nearly equal large values after such operations (a problem known as catastrophic cancellation). Programmers must guard against these issues by validating inputs, applying normalisation techniques, and using algorithms designed to minimise error propagation. In sensitive applications, arbitrary-precision libraries or scaled fixed-point arithmetic may be more appropriate. Additionally, always check for division by zero, which in floating-point systems yields positive or negative infinity rather than an exception, potentially masking logic errors.
