MODULEThis module implements the operations on IEEE extended precisionreals that do not depend on the operating system. We assume that EXTENDED = LONGREAL.; ExtendedFloat
IMPORT LongFloat, FloatMode; PROCEDUREScalb (x: T; n: INTEGER): T RAISES {FloatMode.Trap} = BEGIN RETURN FLOAT (LongFloat.Scalb (FLOAT (x, LONGREAL), n), T); END Scalb; PROCEDURELogb (x: T): T RAISES {FloatMode.Trap} = BEGIN RETURN FLOAT (LongFloat.Logb (FLOAT (x, LONGREAL)), T); END Logb; PROCEDUREILogb (x: T): INTEGER = BEGIN RETURN LongFloat.ILogb (FLOAT (x, LONGREAL)); END ILogb; PROCEDURENextAfter (x, y: T): T RAISES {FloatMode.Trap} = BEGIN RETURN FLOAT (LongFloat.NextAfter (FLOAT (x, LONGREAL), FLOAT (y, LONGREAL)), T); END NextAfter; PROCEDURECopySign (x, y: T): T = BEGIN RETURN FLOAT (LongFloat.CopySign (FLOAT (x, LONGREAL), FLOAT (y, LONGREAL)), T); END CopySign; PROCEDUREFinite (x: T): BOOLEAN = BEGIN RETURN LongFloat.Finite (FLOAT (x, LONGREAL)); END Finite; PROCEDUREIsNaN (x: T): BOOLEAN = BEGIN RETURN LongFloat.IsNaN (FLOAT (x, LONGREAL)); END IsNaN; PROCEDURESign (x: T): [0..1] = BEGIN RETURN LongFloat.Sign (FLOAT (x, LONGREAL)); END Sign; PROCEDUREDiffers (x, y: T): BOOLEAN = BEGIN RETURN LongFloat.Differs (FLOAT (x, LONGREAL), FLOAT (y, LONGREAL)); END Differs; PROCEDUREUnordered (x, y: T): BOOLEAN = BEGIN RETURN LongFloat.Unordered (FLOAT (x, LONGREAL), FLOAT (y, LONGREAL)); END Unordered; PROCEDURESqrt (x: T): T RAISES {FloatMode.Trap} = BEGIN RETURN FLOAT (LongFloat.Sqrt (FLOAT (x, LONGREAL)), T); END Sqrt; PROCEDUREClass (x: T): IEEEClass = BEGIN RETURN LongFloat.Class (FLOAT (x, LONGREAL)); END Class; PROCEDUREFromDecimal ( sign: [0..1]; READONLY digits: ARRAY OF [0..9]; exp: INTEGER): T RAISES {FloatMode.Trap} = BEGIN RETURN FLOAT (LongFloat.FromDecimal (sign, digits, exp), T); END FromDecimal; PROCEDUREToDecimal (x: T): DecimalApprox = BEGIN RETURN LongFloat.ToDecimal (FLOAT (x, LONGREAL)); END ToDecimal; BEGIN END ExtendedFloat.