1 DEFINITION MODULE RealConversions;
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 $
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:
11 ['+'|'-'] digit {digit} ['.' digit {digit}]
12 ['E' ['+'|'-'] digit {digit}]
14 ok := "conversion succeeded"
15 Leading blanks are skipped;
16 Input terminates with a blank or any control character.
19 PROCEDURE StringToLongReal(str: ARRAY OF CHAR;
23 PROCEDURE RealToString(r: REAL;
24 width, digits: INTEGER;
25 VAR str: ARRAY OF CHAR;
27 (* Convert real number "r" to string "str", either in fixed-point or
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.
36 PROCEDURE LongRealToString(r: LONGREAL;
37 width, digits: INTEGER;
38 VAR str: ARRAY OF CHAR;