DragonReal.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last edited by Curry, February 4, 1985 11:02:24 pm PST
DIRECTORY
BitOps, Dragon, IO, QCard;
DragonReal: CEDAR DEFINITIONS =
BEGIN
QINT: TYPE = RECORD [sign: BOOL, val: QCard.QCARD];
Real:  TYPE = MACHINE DEPENDENT RECORD [
sign  (0: 0.. 0): BOOL   ← FALSE,
exp  (0: 1.. 8): [0..400B)  ← 0,
frac0  (0: 9..15): [0.. 20B)  ← 0,
frac1  (0:16..31): CARDINAL ← 0];
RealDbl: TYPE = MACHINE DEPENDENT RECORD [
sign  (0: 0.. 0): BOOL   ← FALSE,
exp  (0: 1..11): [0..4000B)  ← 0,
frac0  (0:12..15): [0.. 20B)  ← 0,
frac1  (0:16..31): CARDINAL ← 0,
frac2  (0:32..47): CARDINAL ← 0,
frac3  (0:48..63): CARDINAL ← 0];
RealFromINT:   PROC [int: INT]  RETURNS [Real];
RealDblFromQINT: PROC [int: QINT] RETURNS [RealDbl];
RealToINT:    PROC [r: Real]  RETURNS [type: NumberType, int: INT];
RealDblToQINT:  PROC [r: RealDbl] RETURNS [type: NumberType, int: QINT];
RealFromDec:   PROC [int: INT,  exp10: INT] RETURNS [Real];
RealDblFromDec:  PROC [int: QINT,  exp10: INT] RETURNS [RealDbl];
RealToDec:    PROC [r: REAL,  precision: NAT ← DefaultSinglePrecision]
RETURNS [type: NumberType, int: INT,  exp10: INT];
RealDblToDec:   PROC [r: RealDbl, precision: NAT ← DefaultDoublePrecision]
RETURNS [type: NumberType, int: QINT,  exp10: INT];
A Decimal number is expressed as int * 10^exp10
DefaultSinglePrecision:  CARDINAL = 7;
MaxSinglePrecision:   CARDINAL = 9;
DefaultDoublePrecision: CARDINAL = 15;
MaxDoublePrecision:  CARDINAL = 17;
The Real*FromDecimal routines may cause exceptions in the normal course of their work. In particular, InexactResult, Overflow, and Underflow. They always use `round to nearest'.
RealDblToINT and RealDblToDecimal routine may cause InexactResult.
NumberType: TYPE = {normal, zero, infinity, nan, integer, decimal};
RealExt: TYPE = RECORD [
type:  NumberType,
sign:  BOOL,
exp:  INT,
double: BOOL,
sticky: BOOL,
sig:  QCard.QCARD];
RoundType: TYPE = MACHINE DEPENDENT {nearest, zero, plus, minus};
SetMode: PROC[rnd: RoundType, rndFixTowardZero, FlushDenormalToZero: BOOL];
ALU: PROC [aHDW, bHDW: HexDblWord, func: Function, mode: Mode]
RETURNS [cHDW: HexDblWord, status: Dragon.PBusFaults];
MUL: PROC [aHDW,bHDW: HexDblWord, function: Function, mode: Mode]
RETURNS [cHDW: HexDblWord, status: Dragon.PBusFaults];
PutHexFP: PUBLIC PROC[st:IO.STREAM, hdw: HexDblWord];
END.