]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-iso/ShortIO.def
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / ShortIO.def
1 (* ShortIO.def provides input/output of SHORTREAL over channels.
2
3 Copyright (C) 2013-2021 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE ShortIO;
28
29 (* Input and output of short real numbers in decimal text form
30 over specified channels. The read result is of the type
31 IOConsts.ReadResults.
32 *)
33
34 IMPORT IOChan;
35
36 (* The text form of a signed fixed-point real number is
37 ["+" | "-"], decimal digit, {decimal digit}, [".",
38 {decimal digit}]
39
40 The text form of a signed floating-point real number is
41 signed fixed-point real number,
42 "E", ["+" | "-"], decimal digit, {decimal digit}
43 *)
44
45 PROCEDURE ReadReal (cid: IOChan.ChanId; VAR real: SHORTREAL);
46 (* Skips leading spaces, and removes any remaining characters
47 from cid that form part of a signed fixed or floating
48 point number. The value of this number is assigned to real.
49 The read result is set to the value allRight, outOfRange,
50 wrongFormat, endOfLine, or endOfInput.
51 *)
52
53 PROCEDURE WriteFloat (cid: IOChan.ChanId; real: SHORTREAL;
54 sigFigs: CARDINAL; width: CARDINAL);
55 (* Writes the value of real to cid in floating-point text form,
56 with sigFigs significant figures, in a field of the given
57 minimum width.
58 *)
59
60 PROCEDURE WriteEng (cid: IOChan.ChanId; real: SHORTREAL;
61 sigFigs: CARDINAL; width: CARDINAL);
62 (* As for WriteFloat, except that the number is scaled with
63 one to three digits in the whole number part, and with an
64 exponent that is a multiple of three.
65 *)
66
67 PROCEDURE WriteFixed (cid: IOChan.ChanId; real: SHORTREAL;
68 place: INTEGER; width: CARDINAL);
69 (* Writes the value of real to cid in fixed-point text form,
70 rounded to the given place relative to the decimal point,
71 in a field of the given minimum width.
72 *)
73
74 PROCEDURE WriteReal (cid: IOChan.ChanId; real: SHORTREAL;
75 width: CARDINAL);
76 (* Writes the value of real to cid, as WriteFixed if the
77 sign and magnitude can be shown in the given width, or
78 otherwise as WriteFloat. The number of places or
79 significant digits depends on the given width.
80 *)
81
82 END ShortIO.