DEFINITION Reals; (* portable *)

(* Implementation of the non-portable components of IEEE REAL and 
LONGREAL manipulation. The routines here are required to do conversion 
of reals to strings and back. 
Implemented by Bernd Moesli, Seminar for Applied Mathematics, 
Swiss Federal Institute of Technology Zürich.
*)

 VAR 
  DefaultFCR: SET;

(* Returns the shifted binary exponent (0 <= e < 256). *)
 PROCEDURE Expo (x: REAL): LONGINT;

(* Returns the shifted binary exponent (0 <= e < 2048). *)
 PROCEDURE ExpoL (x: LONGREAL): LONGINT;

(* Sets the shifted binary exponent. *)
 PROCEDURE SetExpo (e: LONGINT; VAR x: REAL);

(* Sets the shifted binary exponent. *)
 PROCEDURE SetExpoL (e: LONGINT; VAR x: LONGREAL);

(* Convert hexadecimal to REAL. *)
 PROCEDURE Real (h: LONGINT): REAL;

(* Convert hexadecimal to LONGREAL. h and l are the high and low parts.*)
 PROCEDURE RealL (h, l: LONGINT): LONGREAL;

(* Convert REAL to hexadecimal. *)
 PROCEDURE Int (x: REAL): LONGINT;

(* Convert LONGREAL to hexadecimal. h and l are the high and low parts. *)
 PROCEDURE IntL (x: LONGREAL; VAR h, l: LONGINT);

(* Returns 10^e (e <= 308, 308 < e delivers IEEE-code +INF). *)
 PROCEDURE Ten (e: LONGINT): LONGREAL;

(* Returns the NaN code (0 <= c < 8399608) or -1 if not NaN/Infinite. *)
 PROCEDURE NaNCode (x: REAL): LONGINT;

(* Returns the NaN code (0 <= h < 1048576, MIN(LONGINT) <= l <= MAX(LONGINT))
or (-1,-1) if not NaN/Infinite. *)
 PROCEDURE NaNCodeL (x: LONGREAL; VAR h, l: LONGINT);

(* Returns TRUE iff x is NaN/Infinite. *)
 PROCEDURE IsNaN (x: REAL): BOOLEAN;

(* Returns TRUE iff x is NaN/Infinite. *)
 PROCEDURE IsNaNL (x: LONGREAL): BOOLEAN;

(* Returns NaN with specified code (0 <= l < 8399608). *)
 PROCEDURE NaN (l: LONGINT): REAL;

(* Returns NaN with specified code (0 <= h < 1048576, MIN(LONGINT) <= l <= MAX(LONGINT)).
*)
 PROCEDURE NaNL (h, l: LONGINT): LONGREAL;

(* Return state of the floating-point control register. *)
 PROCEDURE FCR (): SET;

(* Set state of floating-point control register.  Traps reset this to the default
& ENTIER resets the rounding mode. *)
 PROCEDURE SetFCR (s: SET);
END Reals.