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