DReal.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Michael Plass, August 9, 1991 2:10 pm PDT
Operations on DREAL numbers.
See IEEE floating point standard for more information.
DIRECTORY Real USING [NumberType];
DReal: CEDAR DEFINITIONS
= BEGIN OPEN Real;
FScale: PROC [a: DREAL, scale: INTEGER] RETURNS [DREAL]; -- a*(2­scale)
Rounding
Fix: PROC [DREAL] RETURNS [DINT];
... rounds toward zero (mode rz).
Round: PROC [DREAL] RETURNS [DINT];
... rounds to nearest, unbiased (mode rn).
Ceiling: PROC [DREAL] RETURNS [DINT];
... rounds toward plus infinity (mode rp).
Floor: PROC [DREAL] RETURNS [DINT];
... rounds toward minus infinity (mode rm).
Decimal conversion
MaxDoublePrecision: CARDINAL = 17;
# of decimal places needed to always exactly reproduce the given real number.
DefaultDoublePrecision: CARDINAL = 15;
# of decimal places that are normally fully significant
PairToReal: PROC [fr: DINT, exp10: INTEGER] RETURNS [DREAL];
... converts the value fr*10**exp10 to real.
RealToPair: PROC [r: DREAL, precision: NAT ¬ DefaultDoublePrecision]
RETURNS
[type: NumberType, fr: DINT, exp10: INTEGER];
... converts value r to fr*10**exp10; fr will have precision significant digits.
END.
Michael Plass, August 9, 1991 1:52:52 pm PDT
Creation, based on Real.mesa