BasicArithmetic.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Michael Plass, August 2, 1991 12:41 pm PDT
Real numbers (32-bit IEEE)
If these routines are implemented as macros, the arguments must not be evaluated twice unless specified.
The compiler generates calls to these procedures using int as type for the parameters or returns; to get the real numbers, the parameter must be loopholed, NOT casted.
By using int the c2c compiler ensures that the C compiler will not convert these parameters to double precision.
Once in the glorious future we will also need 64 bits.
RealNeg:
PROC [a:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealNeg"
};
RealAbs:
PROC [a:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealAbs"
};
RealCompare:
PROC [x, y:
REAL]
RETURNS [Basics.Comparison] ~
TRUSTED
MACHINE
CODE {
"XR←RealCompare"
};
compares x and y
raises RealException as specified by the IEEE standard
RealAdd:
PROC [a, b:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealAdd"
};
RealSub:
PROC [a, b:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealSub"
};
(a-b)
RealMul:
PROC [a, b:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealMul"
};
RealDiv:
PROC [a, b:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealDiv"
};
FloatInt:
PROC [i:
INT32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR𡤏loatInt"
};
FloatCard:
PROC [i:
CARD32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR𡤏loatCard"
};
RealMax:
PROC [a, b:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealMax"
};
RealMin:
PROC [a, b:
REAL32]
RETURNS [
REAL32] ~
TRUSTED
MACHINE
CODE {
"XR←RealMin"
};
RealGt:
PROC [a, b:
REAL32]
RETURNS [
BOOL] ~
TRUSTED
MACHINE
CODE {
"XR←RealGt"
};
(a>b)
RealGe:
PROC [a, b:
REAL32]
RETURNS [
BOOL]~
TRUSTED
MACHINE
CODE {
"XR←RealGe"
};
(a>=b)
Fix: PROC [r: REAL, mode: RoundingMode ← rn] RETURNS [INT];
returns the integer closest to r determined by the mode -- Real.mesa
raises RealException as specified by the IEEE standard
RoundingMode: TYPE = MACHINE DEPENDENT {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).