Previous | Table of Contents | Next |
Return FALSE if x represents a numerical (possibly infinite) value, and TRUE if x does not represent a numerical value. For example, on IEEE implementations, returns TRUE if x is a NaN, FALSE otherwise.
PROCEDURE Sign(x: T): [0..1];
Return the sign bit of x. For non-IEEE implementations, this is the same as ORD(x >= 0); for IEEE implementations, Sign(-0) = 1 and Sign(+0) = 0.
PROCEDURE Differs(x, y: T): BOOLEAN;
Return (x < y OR y < x). Thus, for IEEE implementations, Differs(NaN,x) is always FALSE; for non-IEEE implementations, Differs(x,y) is the same as x # y.
PROCEDURE Unordered(x, y: T): BOOLEAN;
Return NOT (x <= y OR y <= x).
PROCEDURE Sqrt(x: T): T;
Return the square root of T. This must be correctly rounded if FloatMode. IEEE is TRUE.
TYPE IEEEClass = {SignalingNaN, QuietNaN, Infinity, Normal, Denormal, Zero}; PROCEDURE Class(x: T): IEEEClass;
Return the IEEE number class containing x.
END Float.
The FloatMode interface allows you to test the behavior of rounding and of numerical exceptions. On some implementations, it also allows you to change the behavior on a per-thread basis. For definitions of the terms used in this interface, see the ANSI/IEEE Standard 754-1985 for floating-point arithmetic.
INTERFACE FloatMode; CONST IEEE: BOOLEAN = ...; TRUE for fully-compliant IEEE implementations. EXCEPTION Failure;
Raised by attempts to set modes that are not supported by the implementation.
TYPE RoundingMode = {NearestElseEven, TowardMinusInfinity, TowardPlusInfinity, TowardZero, NearestElseAwayFromZero, IBM370, Other};
Rounding modes. the first four are the IEEE modes.
CONST RoundDefault: RoundingMode = ...;
Implementation dependent: the default mode for rounding arithmetic operations, used by a newly forked thread. This also specifies the behavior of the ROUND operation in halfway cases.
PROCEDURE SetRounding(md: RoundingMode) RAISES {Failure};
Change the rounding mode for the calling thread to md, or raise the exception if this cannot be done. This affects the implicit rounding in floating-point operations; it does not affect the ROUND operation. Generally, this can be done only on IEEE implementations and only if md is an IEEE mode.
PROCEDURE GetRounding(): RoundingMode;
Return the rounding mode for the calling thread.
TYPE Flag = {Invalid, Inexact, Overflow, Underflow, DivByZero, IntOverflow, IntDivByZero};
Associated with each thread is a set of boolean status flags recording whether the condition represented by the flag has occurred in the thread since the flag was last reset. The meaning of the first five flags is defined precisely in the IEEE floating-point standard. Roughly, they mean
The meaning of the last two flags is
CONST NoFlags = SET OF Flags {}; PROCEDURE GetFlags(): SET OF Flag;
Return the set of flags for the current thread.
PROCEDURE SetFlags(s: SET OF Flag): SET OF Flag RAISES{Failure};
Set the flags for the current thread to s, and return their previous values.
PROCEDURE ClearFlag(f: Flag);
Turn off the flag f for the current thread.
EXCEPTION Trap(Flag); TYPE Behavior = {Trap, SetFlag, Ignore};
Calls in this interface may raise the Trap exception:
The behavior of an operation that causes one of the flag conditions is either
PROCEDURE SetBehavior(f: Flag; b: Behavior) RAISES {Failure};
Set the behavior of the current thread for the flag f to be b, or raise Failure if this cannot be done.
PROCEDURE GetBehavior(f: Flag): Behavior;
Return the behavior of the current thread for the flag f.
END FloatMode.
Previous | Table of Contents | Next |