| 1 |
(* Library module defined by the International Standard |
| 2 |
Information technology - programming languages |
| 3 |
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language. |
| 4 |
|
| 5 |
Copyright ISO/IEC (International Organization for Standardization |
| 6 |
and International Electrotechnical Commission) 1996-2021. |
| 7 |
|
| 8 |
It may be freely copied for the purpose of implementation (see page |
| 9 |
707 of the Information technology - Programming languages Part 1: |
| 10 |
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *) |
| 11 |
|
| 12 |
DEFINITION MODULE LowReal; |
| 13 |
|
| 14 |
(* Access to underlying properties of the type REAL *) |
| 15 |
|
| 16 |
CONST |
| 17 |
radix = __ATTRIBUTE__ __BUILTIN__ (( <REAL, radix> )) ; (* ZType *) |
| 18 |
places = __ATTRIBUTE__ __BUILTIN__ (( <REAL, places> )) ; (* ZType *) |
| 19 |
expoMin = __ATTRIBUTE__ __BUILTIN__ (( <REAL, expoMin> )) ; (* ZType *) |
| 20 |
expoMax = __ATTRIBUTE__ __BUILTIN__ (( <REAL, expoMax> )) ; (* ZType *) |
| 21 |
large = __ATTRIBUTE__ __BUILTIN__ (( <REAL, large> )) ; (* RType *) |
| 22 |
small = __ATTRIBUTE__ __BUILTIN__ (( <REAL, small> )) ; (* RType *) |
| 23 |
IEC559 = __ATTRIBUTE__ __BUILTIN__ (( <REAL, IEC559> )) ; (* BOOLEAN *) |
| 24 |
LIA1 = __ATTRIBUTE__ __BUILTIN__ (( <REAL, LIA1> )) ; (* BOOLEAN *) |
| 25 |
ISO = __ATTRIBUTE__ __BUILTIN__ (( <REAL, ISO> )) ; (* BOOLEAN *) |
| 26 |
IEEE = __ATTRIBUTE__ __BUILTIN__ (( <REAL, IEEE> )) ; (* BOOLEAN *) |
| 27 |
rounds = __ATTRIBUTE__ __BUILTIN__ (( <REAL, rounds> )) ; (* BOOLEAN *) |
| 28 |
gUnderflow = __ATTRIBUTE__ __BUILTIN__ (( <REAL, gUnderflow> )) ; (* BOOLEAN *) |
| 29 |
exception = __ATTRIBUTE__ __BUILTIN__ (( <REAL, exception> )) ; (* BOOLEAN *) |
| 30 |
extend = __ATTRIBUTE__ __BUILTIN__ (( <REAL, extend> )) ; (* BOOLEAN *) |
| 31 |
nModes = __ATTRIBUTE__ __BUILTIN__ (( <REAL, nModes> )) ; (* ZType *) |
| 32 |
|
| 33 |
TYPE |
| 34 |
Modes = PACKEDSET OF [0..nModes-1]; |
| 35 |
|
| 36 |
PROCEDURE exponent (x: REAL): INTEGER; |
| 37 |
(* Returns the exponent value of x *) |
| 38 |
|
| 39 |
PROCEDURE fraction (x: REAL): REAL; |
| 40 |
(* Returns the significand (or significant part) of x *) |
| 41 |
|
| 42 |
PROCEDURE sign (x: REAL): REAL; |
| 43 |
(* Returns the signum of x *) |
| 44 |
|
| 45 |
PROCEDURE succ (x: REAL): REAL; |
| 46 |
(* Returns the next value of the type REAL greater than x *) |
| 47 |
|
| 48 |
PROCEDURE ulp (x: REAL): REAL; |
| 49 |
(* Returns the value of a unit in the last place of x *) |
| 50 |
|
| 51 |
PROCEDURE pred (x: REAL): REAL; |
| 52 |
(* Returns the previous value of the type REAL less than x *) |
| 53 |
|
| 54 |
PROCEDURE intpart (x: REAL): REAL; |
| 55 |
(* Returns the integer part of x *) |
| 56 |
|
| 57 |
PROCEDURE fractpart (x: REAL): REAL; |
| 58 |
(* Returns the fractional part of x *) |
| 59 |
|
| 60 |
PROCEDURE scale (x: REAL; n: INTEGER): REAL; |
| 61 |
(* Returns the value of x * radix ** n *) |
| 62 |
|
| 63 |
PROCEDURE trunc (x: REAL; n: INTEGER): REAL; |
| 64 |
(* Returns the value of the first n places of x *) |
| 65 |
|
| 66 |
PROCEDURE round (x: REAL; n: INTEGER): REAL; |
| 67 |
(* Returns the value of x rounded to the first n places *) |
| 68 |
|
| 69 |
PROCEDURE synthesize (expart: INTEGER; frapart: REAL): REAL; |
| 70 |
(* Returns a value of the type REAL constructed from the given expart and frapart *) |
| 71 |
|
| 72 |
PROCEDURE setMode (m: Modes); |
| 73 |
(* Sets status flags appropriate to the underlying implementation of the type REAL *) |
| 74 |
|
| 75 |
PROCEDURE currentMode (): Modes; |
| 76 |
(* Returns the current status flags in the form set by setMode *) |
| 77 |
|
| 78 |
PROCEDURE IsLowException (): BOOLEAN; |
| 79 |
(* Returns TRUE if the current coroutine is in the exceptional execution state |
| 80 |
because of the raising of an exception in a routine from this module; otherwise |
| 81 |
returns FALSE. |
| 82 |
*) |
| 83 |
|
| 84 |
END LowReal. |
| 85 |
|