Oberon || Library || Module Index || Search Engine || Definition || Module
CONST available = TRUE;
(* rounding modes *) CONST toNearest = 0; CONST towardZero = 1; CONST towardMinusInfinity = 2; CONST towardPlusInfinity = 3;
(* rounding precision *) CONST extended = 0; single = 1; double = 2;
(* exceptions *) CONST branchOnUnordered = 0; CONST signalingNotANumber = 1; CONST operandError = 2; CONST overflow = 3; CONST underflow = 4; CONST divideByZero = 5; CONST inexactOperation = 6; CONST inexactDecimalInput = 7; CONST floatlen = 4; (* length of a single precision real number *)
PROCEDURE FACOS(x: LONGREAL) : LONGREAL; PROCEDURE FASIN(x: LONGREAL) : LONGREAL; PROCEDURE FATAN(x: LONGREAL) : LONGREAL; PROCEDURE FATANH(x: LONGREAL) : LONGREAL; PROCEDURE FCOS(x: LONGREAL) : LONGREAL; PROCEDURE FCOSH(x: LONGREAL) : LONGREAL; PROCEDURE FETOX(x: LONGREAL) : LONGREAL; PROCEDURE FETOXM1(x: LONGREAL) : LONGREAL; PROCEDURE FGETEXP(x: LONGREAL) : LONGREAL; PROCEDURE FGETMAN(x: LONGREAL) : LONGREAL; PROCEDURE FLOG10(x: LONGREAL) : LONGREAL; PROCEDURE FLOG2(x: LONGREAL) : LONGREAL; PROCEDURE FLOGN(x: LONGREAL) : LONGREAL; PROCEDURE FLOGNP1(x: LONGREAL) : LONGREAL; PROCEDURE FSIN(x: LONGREAL) : LONGREAL; PROCEDURE FSINH(x: LONGREAL) : LONGREAL; PROCEDURE FSQRT(x: LONGREAL) : LONGREAL; PROCEDURE FTAN(x: LONGREAL) : LONGREAL; PROCEDURE FTANH(x: LONGREAL) : LONGREAL; PROCEDURE FTENTOX(x: LONGREAL) : LONGREAL; PROCEDURE FTWOTOX(x: LONGREAL) : LONGREAL;
PROCEDURE GetExceptionEnable(VAR exceptions: SET); PROCEDURE SetExceptionEnable(exceptions: SET);
PROCEDURE GetRoundingMode(VAR precision, mode: INTEGER); PROCEDURE SetRoundingMode(precision, mode: INTEGER);
PROCEDURE RealToFloat(real: LONGREAL; VAR float: ARRAY OF BYTE); PROCEDURE FloatToReal(float: ARRAY OF BYTE; VAR real: LONGREAL);
The constant available is TRUE if a MC68881 or upward compatible processor is present. Otherwise available is FALSE and all operations are no-operations. This allows some system modules to take advantage of known floating processors in a portable manner.
The procedures FACOS to FTWOTOX execute the equally named instructions.
The MC68881 supports 8 exceptions which can be separately enabled or disabled:
The MC68881 supports four rounding modes:
_______________________________________________________________ |rounding mode examples for real to integer conversion| |_________________________-1.9________-1.1________1.1______1.9| |toNearest -2 -1 1 2 | |towardZero -1 -1 1 1 | |towardMinusInfinity -2 -2 1 1 | |towardPlusInfinity -1 -1 2 2 | |_____________________________________________________________|
Note that ENTIER is a conversion with rounding mode towards minus infinity. The inline code of the compiler for ENTIER saves the current rounding mode, sets the rounding mode towards minus infinity, executes the conversion, and restores the old rounding mode. The rounding precision is either extended, single, or double. The rounding precision is set to extended at beginning of execution and must not be changed (else floating point operations would behave unexpected, e.g. the precision of LONGREAL and REAL differs from the specifications of Reals). GetRoundingMode returns current rounding mode and precision. SetRoundingMode sets the rounding precision to precision and the rounding mode to mode.
The Oberon compiler maps REAL to the 8-byte double precision format and LONGREAL to the 12-byte extended precision format and does not provide a basic datatype for the 4-byte single precision format. RealToFloat and FloatToReal allow to convert to and from the 4-byte single precision format (e.g. to export or import real values in binary format to other programming languages). Both procedures use ARRAY OF BYTE for the 4-byte real value for convenience. The constant floatlen specifies the necessary number of bytes to hold a single precision real value.
IEEE IEEE floating point formats Reals real conversions SysSignals floating point exceptions
Oberon || Library || Module Index || Search Engine || Definition || Module