

DEFINITION MODULE NUM;

FROM SYSTEM IMPORT UNSIGNED_32;                            (*  SOLARIS *)

TYPE
   LONGCARD  =  UNSIGNED_32;                               (*  SOLARIS *)

CONST
   MaxLongInt       = 2147483647;
   LgMaxLongInt1    = 31;              (* Log (MaxLongInt+1) in base 2. *)
   t                = 53;              (* Precision in LONGREAL,        *)
                                       (* - 53 for SUN ; 52 for PC's  - *)
   MaxTwoExp        = 64;              (* All powers of 2 are represen- *)
                                       (* ted exactly in LONGREAL !     *)
VAR
   (* These should be constants, but some compilers do not allow it.    *)
   MaxLongIntLR,                       (* = MaxLongInt, in LONGREAL.    *)
   MaxIntLongReal,                     (* Max. value represented        *)
                                       (* exactly as a LONGREAL.        *)
   MaxLongReal,                        (* Max. value for a LONGREAL.    *)
   ZeroLR,                             (* = 0.                          *)
   Point5LR,                           (* = 0.5.                        *)
   OneLR,                              (* = 1.                          *)
   TwoLR,                              (* = 2.                          *)
   ThreeLR,                            (* = 3.                          *)
   FourLR : LONGREAL;                  (* = 4.                          *)
   TwoExp : ARRAY[0..MaxTwoExp] OF LONGREAL;  (* TwoExp[i] = 2^i.       *)
   hLR,                                (* 2^{-t}                        *)
   chLR,                               (* 1 - hLR                       *)
   jLR    : LONGREAL;                  (* hLR + hLR/2                   *)
   Pi     : LONGREAL;                  (* Value of pi = 3.14159...      *)
   e      : LONGREAL;                  (* Base of the natural log.      *)


PROCEDURE S (x : LONGREAL) : LONGREAL;


PROCEDURE Pow (x, y : LONGREAL) : LONGREAL;


PROCEDURE Sqrt (x : LONGREAL) : LONGREAL;


PROCEDURE Exp (x : LONGREAL) : LONGREAL;


PROCEDURE Ln (x : LONGREAL) : LONGREAL;


PROCEDURE Lg (x : LONGREAL) : LONGREAL;


PROCEDURE Sin (x : LONGREAL) : LONGREAL;


PROCEDURE Cos (x : LONGREAL) : LONGREAL;


PROCEDURE IToLI (i : INTEGER) : LONGINT;


PROCEDURE IToLR (i : INTEGER) : LONGREAL;


PROCEDURE LIToLR (i : LONGINT) : LONGREAL;


PROCEDURE LCToLR (c : LONGCARD) : LONGREAL;


PROCEDURE REALToLR (x : REAL) : LONGREAL;


PROCEDURE StringToLR (S : ARRAY OF CHAR) : LONGREAL;


PROCEDURE LRToString (x : LONGREAL;  i : INTEGER;  S : ARRAY OF CHAR);


PROCEDURE StringToLI (S : ARRAY OF CHAR) : LONGINT;


PROCEDURE ModLR (x, y : LONGREAL) : LONGREAL;


PROCEDURE TruncLR (x : LONGREAL) : LONGREAL;


PROCEDURE RoundLR (x : LONGREAL) : LONGREAL;


PROCEDURE Trunc (x : LONGREAL) : LONGINT;


PROCEDURE Round (x : LONGREAL) : LONGINT;


PROCEDURE ReadLI (VAR i : LONGINT);

PROCEDURE ReadLC (VAR c : LONGCARD);

PROCEDURE ReadLR (VAR x : LONGREAL);

PROCEDURE WriteLI (i : LONGINT;  s : CARDINAL);


PROCEDURE WriteLC (c : LONGCARD;  s : CARDINAL);


PROCEDURE WriteLR (x : LONGREAL;  I, J, K : CARDINAL);


END NUM.
