Debian Codegraph @

gcc/m2/gm2-libs-iso/LongStr.def

raw
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 LongStr;
13
14 (* LONGREAL/string conversions *)
15
16 IMPORT
17 ConvTypes;
18
19 TYPE
20 (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)
21 ConvResults = ConvTypes.ConvResults;
22
23 (* the string form of a signed fixed-point real number is
24 ["+" | "-"], decimal digit, {decimal digit}, [".",
25 {decimal digit}]
26 *)
27
28 (* the string form of a signed floating-point real number is
29 signed fixed-point real number, "E", ["+" | "-"],
30 decimal digit, {decimal digit}
31 *)
32
33 PROCEDURE StrToReal (str: ARRAY OF CHAR; VAR real: LONGREAL;
34 VAR res: ConvResults);
35 (* Ignores any leading spaces in str. If the subsequent characters
36 in str are in the format of a signed real number, assigns a
37 corresponding value to real. Assigns a value indicating the
38 format of str to res.
39 *)
40
41 PROCEDURE RealToFloat (real: LONGREAL; sigFigs: CARDINAL;
42 VAR str: ARRAY OF CHAR);
43 (* Converts the value of real to floating-point string form, with
44 sigFigs significant figures, and copies the possibly truncated
45 result to str.
46 *)
47
48 PROCEDURE RealToEng (real: LONGREAL; sigFigs: CARDINAL;
49 VAR str: ARRAY OF CHAR);
50 (* Converts the value of real to floating-point string form, with
51 sigFigs significant figures, and copies the possibly truncated
52 result to str. The number is scaled with one to three digits
53 in the whole number part and with an exponent that is a
54 multiple of three.
55 *)
56
57 PROCEDURE RealToFixed (real: LONGREAL; place: INTEGER;
58 VAR str: ARRAY OF CHAR);
59 (* Converts the value of real to fixed-point string form, rounded
60 to the given place relative to the decimal point, and copies
61 the possibly truncated result to str.
62 *)
63
64 PROCEDURE RealToStr (real: LONGREAL; VAR str: ARRAY OF CHAR);
65 (* Converts the value of real as RealToFixed if the sign and
66 magnitude can be shown within the capacity of str, or
67 otherwise as RealToFloat, and copies the possibly truncated
68 result to str. The number of places or significant digits
69 depend on the capacity of str.
70 *)
71
72 END LongStr.
73