The OpenD Programming Language

IeeeFlags

IEEE exception status flags ('sticky bits')

These flags indicate that an exceptional floating-point condition has occurred. They indicate that a NaN or an infinity has been generated, that a result is inexact, or that a signalling NaN has been encountered. If floating-point exceptions are enabled (unmasked), a hardware exception will be generated instead of setting these flags.

Members

Properties

divByZero
bool divByZero [@property getter]

An infinity was generated by division by zero

inexact
bool inexact [@property getter]

The result cannot be represented exactly, so rounding occurred.

invalid
bool invalid [@property getter]

A machine NaN was generated.

overflow
bool overflow [@property getter]

An infinity was generated by overflow

underflow
bool underflow [@property getter]

A zero was generated by underflow

Examples

import std.math.traits : isNaN;

static void func() {
    int a = 10 * 10;
}
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