| 1 |
(* Library module defined by the International Standard |
| 2 |
Information technology - programming languages |
| 3 |
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language. |
| 4 |
|
| 5 |
Copyright ISO/IEC (International Organization for Standardization |
| 6 |
and International Electrotechnical Commission) 1996-2021. |
| 7 |
|
| 8 |
It may be freely copied for the purpose of implementation (see page |
| 9 |
707 of the Information technology - Programming languages Part 1: |
| 10 |
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *) |
| 11 |
|
| 12 |
DEFINITION MODULE LongIO; |
| 13 |
|
| 14 |
(* Input and output of long real numbers in decimal text form |
| 15 |
over specified channels. The read result is of the type |
| 16 |
IOConsts.ReadResults. |
| 17 |
*) |
| 18 |
|
| 19 |
IMPORT IOChan; |
| 20 |
|
| 21 |
(* The text form of a signed fixed-point real number is |
| 22 |
["+" | "-"], decimal digit, {decimal digit}, [".", |
| 23 |
{decimal digit}] |
| 24 |
|
| 25 |
The text form of a signed floating-point real number is |
| 26 |
signed fixed-point real number, |
| 27 |
"E", ["+" | "-"], decimal digit, {decimal digit} |
| 28 |
*) |
| 29 |
|
| 30 |
PROCEDURE ReadReal (cid: IOChan.ChanId; VAR real: LONGREAL); |
| 31 |
(* Skips leading spaces, and removes any remaining characters |
| 32 |
from cid that form part of a signed fixed or floating |
| 33 |
point number. The value of this number is assigned to real. |
| 34 |
The read result is set to the value allRight, outOfRange, |
| 35 |
wrongFormat, endOfLine, or endOfInput. |
| 36 |
*) |
| 37 |
|
| 38 |
PROCEDURE WriteFloat (cid: IOChan.ChanId; real: LONGREAL; |
| 39 |
sigFigs: CARDINAL; width: CARDINAL); |
| 40 |
(* Writes the value of real to cid in floating-point text form, |
| 41 |
with sigFigs significant figures, in a field of the given |
| 42 |
minimum width. |
| 43 |
*) |
| 44 |
|
| 45 |
PROCEDURE WriteEng (cid: IOChan.ChanId; real: LONGREAL; |
| 46 |
sigFigs: CARDINAL; width: CARDINAL); |
| 47 |
(* As for WriteFloat, except that the number is scaled with |
| 48 |
one to three digits in the whole number part, and with an |
| 49 |
exponent that is a multiple of three. |
| 50 |
*) |
| 51 |
|
| 52 |
PROCEDURE WriteFixed (cid: IOChan.ChanId; real: LONGREAL; |
| 53 |
place: INTEGER; width: CARDINAL); |
| 54 |
(* Writes the value of real to cid in fixed-point text form, |
| 55 |
rounded to the given place relative to the decimal point, |
| 56 |
in a field of the given minimum width. |
| 57 |
*) |
| 58 |
|
| 59 |
PROCEDURE WriteReal (cid: IOChan.ChanId; real: LONGREAL; |
| 60 |
width: CARDINAL); |
| 61 |
(* Writes the value of real to cid, as WriteFixed if the |
| 62 |
sign and magnitude can be shown in the given width, or |
| 63 |
otherwise as WriteFloat. The number of places or |
| 64 |
significant digits depends on the given width. |
| 65 |
*) |
| 66 |
|
| 67 |
END LongIO. |
| 68 |
|