IeeeFloat.mesa - adaptation of Real.mesa+Ieee.mesa for compiler use
Copyright © 1985 by Xerox Corporation. All rights reserved.
Satterthwaite, April 16, 1986 3:03:48 pm PST
Russ Atkinson (RRA) March 6, 1985 10:11:12 pm PST
Real: DEFINITIONS = {
extended format
NumberType: TYPE = {normal, zero, infinity, nan};
Extended: TYPE = RECORD [
type: NumberType,
sign: BOOL,
exp: INTEGER,
frac: LONG CARDINAL];
modes
RoundingMode: TYPE = {rn, rz, rm, rp};
rn: Round to nearest (unbiased)
rz: Round to zero (truncate)
rp: Round to plus infinity (round up)
rm: Round to minus infinity (round down)
NormalizationMode: TYPE = {warning, normalizing};
Mode: TYPE = RECORD [
nm: NormalizationMode ← warning,
round: RoundingMode ← rn];
Constants
PlusZero: REAL = LOOPHOLE[(00000000000b).LONG];
MinusZero: REAL = LOOPHOLE[20000000000b];
PlusInfinity: REAL = LOOPHOLE[17740000000b];
MinusInfinity: REAL = LOOPHOLE[37740000000b];
TrapNonTrappingNaN: LONG CARDINAL = (1).LONG;
TrapTrappingNaN: LONG CARDINAL = (2).LONG;
Exceptions
Flag: TYPE = BOOLFALSE;
Exception: TYPE = {
fixOverflow, inexactResult, invalidOperation, divisionByZero, overflow, underflow};
ExceptionFlags: TYPE = PACKED ARRAY Exception OF Flag;
NoExceptions: ExceptionFlags = ALL[FALSE];
Operations
RealException: SIGNAL [flags: ExceptionFlags];
RealToExtended: PROC [a: REAL] RETURNS [Extended];
ExtendedToReal: PROC [e: Extended] RETURNS [REAL];
Abs: PROC [a: REAL] RETURNS [REAL];
Negate: PROC [a: REAL] RETURNS [REAL];
PairToReal: PROC [fr: LONG INTEGER, exp10: INTEGER] RETURNS [REAL];
}.