ack/lang/m2/libm2/RealConversions.def

42 lines
1.3 KiB
Modula-2
Raw Normal View History

1987-05-22 17:15:09 +00:00
DEFINITION MODULE RealConversions;
1988-02-19 15:54:01 +00:00
(*
Module: string-to-real and real-to-string conversions
Author: Ceriel J.H. Jacobs
1994-06-24 14:02:31 +00:00
Version: $Id$
1988-02-19 15:54:01 +00:00
*)
1987-05-22 17:15:09 +00:00
PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
(* Convert string "str" to a real number "r" according to the syntax:
['+'|'-'] digit {digit} ['.' digit {digit}]
1987-06-26 15:59:52 +00:00
['E' ['+'|'-'] digit {digit}]
1987-05-22 17:15:09 +00:00
ok := "conversion succeeded"
Leading blanks are skipped;
Input terminates with a blank or any control character.
*)
1988-06-30 16:32:54 +00:00
PROCEDURE StringToLongReal(str: ARRAY OF CHAR;
VAR r: LONGREAL;
VAR ok: BOOLEAN);
1987-05-22 17:15:09 +00:00
PROCEDURE RealToString(r: REAL;
1989-03-08 17:28:08 +00:00
width, digits: INTEGER;
1987-05-22 17:15:09 +00:00
VAR str: ARRAY OF CHAR;
VAR ok: BOOLEAN);
(* Convert real number "r" to string "str", either in fixed-point or
exponent notation.
"digits" is the number digits to the right of the decimal point,
"width" is the maximum width of the notation.
If digits < 0, exponent notation is used, otherwise fixed-point.
If fewer than "width" characters are needed, leading blanks are inserted.
If the representation does not fit in "width", then ok is set to FALSE.
*)
1988-06-30 16:32:54 +00:00
PROCEDURE LongRealToString(r: LONGREAL;
1989-03-08 17:28:08 +00:00
width, digits: INTEGER;
1988-06-30 16:32:54 +00:00
VAR str: ARRAY OF CHAR;
VAR ok: BOOLEAN);
1987-05-22 17:15:09 +00:00
END RealConversions.