IeeeFlags

IEEE exception status flags

These flags indicate that an exceptional floating-point condition has occured. They indicate that a NaN or an infinity has been generated, that a result is inexact, or that a signalling NaN has been encountered. The return values of the properties should be treated as booleans, although each is returned as an int, for speed.

Members

Functions

divByZero
int divByZero()

An infinity was generated by division by zero (example: x = 3/0.0; )

inexact
int inexact()

The result cannot be represented exactly, so rounding occured. (example: x = sin(0.1); )

invalid
int invalid()

A machine NaN was generated. (example: x = real.infinity * 0.0; )

overflow
int overflow()

An infinity was generated by overflow (example: x = real.max*2;)

underflow
int underflow()

A zero was generated by underflow (example: x = real.min_normal*real.epsilon/2;)

Examples

real a=3.5;
// Set all the flags to zero
resetIeeeFlags();
assert(!ieeeFlags.divByZero);
// Perform a division by zero.
a/=0.0L;
assert(a==real.infinity);
assert(ieeeFlags.divByZero);
// Create a NaN
a*=0.0L;
assert(ieeeFlags.invalid);
assert(isNaN(a));

// Check that calling func() has no effect on the
// status flags.
IeeeFlags f = ieeeFlags;
func();
assert(ieeeFlags == f);

Meta