Lably
Skip to content

Arithmetic underflow

Computer programming condition

  • 3 min read
  • 2 chapters

Related on Lably

Through Computer program, Computer memory and Data type

Arithmetic underflow can occur when the true result of a floating-point operation is smaller in magnitude (that is, closer to zero) than the smallest value representable as a normal floating-point number in the target datatype. Underflow can in part be regarded as negative overflow of the exponent of the floating-point value. For example, if the exponent part can represent values from −128 to 127, then a result with a value less than −128 may cause underflow.

Underflow gap

The interval between −fminN and fminN, where fminN is the smallest positive normal floating-point value, is called the underflow gap. This is because the size of this interval is many orders of magnitude larger than the distance between adjacent normal floating-point values just outside the gap. For instance, if the floating-point datatype can represent 20 bits, the underflow gap is 221 times larger than the absolute distance between adjacent floating-point values just outside the gap.

In older designs, the underflow gap had just one usable value, zero. When an underflow occurred, the true result was replaced by zero (either directly by the hardware, or by system software handling the primary underflow condition). This replacement is called "flush to zero".

The 1984 edition of IEEE 754 introduced subnormal numbers. The subnormal numbers (including zero) fill the underflow gap with values where the absolute distance between adjacent values is the same as for adjacent values just outside the underflow gap. This enables "gradual underflow", where a nearest subnormal value is used, just as a nearest normal value is used when possible. Even when using gradual underflow, the nearest value may be zero.

The absolute distance between adjacent floating-point values just outside the gap is called the machine epsilon, defined as the difference between 1 and the next larger floating point number. This is the minimum value of ϵ that satisfies fl⁡(1+ϵ)>fl⁡(1), where fl is a function which converts the real value into the floating-point representation. While the machine epsilon is not to be confused with the underflow level (assuming subnormal numbers), it is closely related. The machine epsilon is dependent on the number of bits which make up the significand, whereas the underflow level depends on the number of digits which make up the exponent field. In most floating-point systems, the underflow level is smaller than the machine epsilon.

Sign in to keep reading

One more chapter is free with a Lably account.

More in From Lably lessons