1987-05-13 14:36:45 +00:00
|
|
|
DEFINITION MODULE RealInOut;
|
1988-02-19 15:54:01 +00:00
|
|
|
(*
|
|
|
|
Module: InOut for REAL numbers
|
|
|
|
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
|
|
|
|
Version: $Header$
|
|
|
|
*)
|
1987-05-13 14:36:45 +00:00
|
|
|
|
|
|
|
VAR Done: BOOLEAN;
|
|
|
|
|
|
|
|
PROCEDURE ReadReal(VAR x: REAL);
|
|
|
|
(* Read a real number "x" according to the syntax:
|
|
|
|
|
|
|
|
['+'|'-'] digit {digit} ['.' digit {digit}]
|
1987-05-22 17:15:09 +00:00
|
|
|
[('E'|'e') ['+'|'-'] digit {digit}]
|
1987-05-13 14:36:45 +00:00
|
|
|
|
|
|
|
Done := "a number was read".
|
|
|
|
Input terminates with a blank or any control character.
|
|
|
|
When reading from a terminal, backspacing may be done by either
|
|
|
|
DEL or BACKSPACE, depending on the implementation of ReadString.
|
|
|
|
*)
|
|
|
|
|
|
|
|
PROCEDURE WriteReal(x: REAL; n: CARDINAL);
|
|
|
|
(* Write x using n characters.
|
|
|
|
If fewer than n characters are needed, leading blanks are inserted.
|
|
|
|
*)
|
|
|
|
|
1989-03-08 17:28:08 +00:00
|
|
|
PROCEDURE WriteFixPt(x: REAL; n, k: CARDINAL);
|
|
|
|
(* Write x in fixed-point notation usign n characters with k digits
|
|
|
|
after the decimal point. If fewer than n characters are needed,
|
|
|
|
leading blanks are inserted.
|
|
|
|
*)
|
|
|
|
|
1987-05-13 14:36:45 +00:00
|
|
|
PROCEDURE WriteRealOct(x: REAL);
|
1987-05-22 17:15:09 +00:00
|
|
|
(* Write x in octal words.
|
1987-05-13 14:36:45 +00:00
|
|
|
*)
|
|
|
|
END RealInOut.
|