Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / RealConver.def
1 DEFINITION MODULE RealConversions;
2 (*
3   Module:       string-to-real and real-to-string conversions
4   Author:       Ceriel J.H. Jacobs
5   Version:      $Id: RealConver.def,v 1.6 1994/06/24 12:49:21 ceriel Exp $
6 *)
7
8   PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
9   (* Convert string "str" to a real number "r" according to the syntax:
10      
11         ['+'|'-'] digit {digit} ['.' digit {digit}]
12         ['E' ['+'|'-'] digit {digit}]
13
14      ok := "conversion succeeded"
15      Leading blanks are skipped;
16      Input terminates with a blank or any control character.
17   *)
18
19   PROCEDURE StringToLongReal(str: ARRAY OF CHAR;
20                              VAR r: LONGREAL;
21                              VAR ok: BOOLEAN);
22
23   PROCEDURE RealToString(r: REAL;
24                          width, digits: INTEGER;
25                          VAR str: ARRAY OF CHAR;
26                          VAR ok: BOOLEAN);
27   (* Convert real number "r" to string "str", either in fixed-point or
28      exponent notation.
29      "digits" is the number digits to the right of the decimal point,
30      "width" is the maximum width of the notation.
31      If digits < 0, exponent notation is used, otherwise fixed-point.
32      If fewer than "width" characters are needed, leading blanks are inserted.
33      If the representation does not fit in "width", then ok is set to FALSE.
34   *)
35
36   PROCEDURE LongRealToString(r: LONGREAL;
37                          width, digits: INTEGER;
38                          VAR str: ARRAY OF CHAR;
39                          VAR ok: BOOLEAN);
40
41 END RealConversions.