<<>> <> <> <> <> <> <> <> <> <> <<>> <> <> Real: CEDAR DEFINITIONS = BEGIN FScale: PROC [a: REAL, scale: INTEGER] RETURNS [REAL]; -- a*(2­scale) <> Fix: PROC [REAL] RETURNS [INT]; <<... rounds toward zero (mode rz).>> <<>> Round: PROC [REAL] RETURNS [INT]; <<... rounds to nearest, unbiased (mode rn).>> <<>> Ceiling: PROC [REAL] RETURNS [INT]; <<... rounds toward plus infinity (mode rp).>> <<>> Floor: PROC [REAL] RETURNS [INT]; <<... rounds toward minus infinity (mode rm).>> <<>> <> MaxSinglePrecision: CARDINAL = 9; <<# of decimal places needed to always exactly reproduce the given real number.>> DefaultSinglePrecision: CARDINAL = 7; <<# of decimal places that are normally fully significant>> PairToReal: PROC [fr: INT, exp10: INTEGER] RETURNS [REAL]; <<... converts the value fr*10**exp10 to real.>> <<>> RealToPair: PROC [r: REAL, precision: NAT ¬ DefaultSinglePrecision] RETURNS [type: NumberType, fr: INT, exp10: INTEGER]; <<... converts value r to fr*10**exp10; fr will have precision significant digits.>> <<>> <> PlusZero: REAL = LOOPHOLE[LONG[00000000000B]]; MinusZero: REAL = LOOPHOLE[20000000000B]; PlusInfinity: REAL = LOOPHOLE[17740000000B]; MinusInfinity: REAL = LOOPHOLE[37740000000B]; LargestNumber: REAL = LOOPHOLE[17737777777B]; -- almost infinity SmallestNormalizedNumber: REAL = LOOPHOLE[00040000000B]; NonTrappingNaN: REAL = LOOPHOLE[17740000001B]; TrappingNaN: REAL = LOOPHOLE[17740000002B]; <> TrapNonTrappingNaN: CARD = LONG[1]; TrapTrappingNaN: CARD = LONG[2]; AddInfinityNaN: CARD = LONG[3]; MultiplyInfinityNaN: CARD = LONG[4]; DivideInfinityNaN: CARD = LONG[5]; SqRtNaN: CARD = LONG[6]; <> <> Flag: TYPE = BOOL ¬ FALSE; <<>> Exception: TYPE = MACHINE DEPENDENT{ fixOverflow, inexactResult, invalidOperation, divisionByZero, overflow, underflow}; ExceptionFlags: TYPE = PACKED ARRAY Exception OF Flag; <<>> NoExceptions: ExceptionFlags = ALL[FALSE]; AllExceptions: ExceptionFlags = ALL[TRUE]; UsualExceptions: ExceptionFlags = [ fixOverflow: TRUE, invalidOperation: TRUE, divisionByZero: TRUE, overflow: TRUE ]; NumberType: TYPE = MACHINE DEPENDENT { normal, zero, infinity, nan }; Extended: TYPE = RECORD [type: NumberType, sign: BOOL, exp: INTEGER, frac: CARD]; <> RealException: SIGNAL [flags: ExceptionFlags, vp: REF Extended] RETURNS [clientFixup: BOOL ¬ FALSE]; RealError: ERROR; <> <<>> <<>> GetStickyFlags: PROC RETURNS [ExceptionFlags]; SetStickyFlags: PROC [new: ExceptionFlags ¬ NoExceptions] RETURNS [old: ExceptionFlags]; <> END. <<4-Feb-81 18:42:11, L. Stewart, fixed TrappingNaN to be of type REAL>> <> <> <> <> <> <> <> <> <> <> <> <<>>