Debian Codegraph @

gcc/testsuite/gm2/isolib/run/pass/real1.mod

raw
1 (* Copyright (C) 2008 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 MODULE real1 ;
19
20
21 FROM StringConvert IMPORT LongrealToString, ToSigFig ;
22 FROM SFIO IMPORT WriteS ;
23 FROM FIO IMPORT StdOut ;
24 FROM StrIO IMPORT WriteString, WriteLn ;
25 FROM NumberIO IMPORT WriteCard ;
26 FROM DynamicStrings IMPORT String, InitString ;
27
28
29 VAR
30 i: CARDINAL ;
31 s: String ;
32 BEGIN
33 FOR i := 2 TO 30 DO
34 WriteString('correct to ') ; WriteCard(i, 2) ;
35 WriteString(' ') ;
36 s := WriteS(StdOut, ToSigFig(InitString('1.23456789012345678901234567890'), i)) ; WriteLn
37 END ;
38 s := WriteS(StdOut, LongrealToString(1.23456789012345678901234567890, 0, 0)) ;
39 WriteLn ;
40 FOR i := 2 TO 30 DO
41 WriteString('pi correct to ') ; WriteCard(i, 2) ;
42 WriteString(' ') ;
43 s := WriteS(StdOut, ToSigFig(InitString('3.14159265358979323846264338327950288419716939937510'), i)) ; WriteLn
44 END ;
45 WriteString('now printing pi 3.1415926535897932384626433832795028841971693993751') ; WriteLn ;
46 WriteString('longreal printed ') ;
47 s := WriteS(StdOut, LongrealToString(3.1415926535897932384626433832795028841971693993751, 0, 0)) ; WriteLn
48 END real1.