File: format.usg

package info (click to toggle)
maxima 5.9.1-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 32,272 kB
  • ctags: 14,123
  • sloc: lisp: 145,126; fortran: 14,031; tcl: 10,052; sh: 3,313; perl: 1,766; makefile: 1,748; ansic: 471; awk: 7
file content (117 lines) | stat: -rw-r--r-- 2,939 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Pretty printing of floating point numbers.
Do LOADFILE(FORMAT,FASL,DSK,SHARE);

Nothing is changed unless you do FLOATFORMAT:TRUE; (default is FALSE)
Then all floating point numbers are printed in a field of FLOATWIDTH
character positions (default 10) with FLOATPREC significant figures
(default 3) and FLOATINT (default 1) figures before the decimal point.
(FLOATINT may also be a list of 3 integers, in which the first gives the
no. of digits before the decimal point and the other two specify the
range of powers of 10 for which the "E" format is not used.)

Alternately you can do FLOATFORMAT:'F; in which case the "E" notation
is not used and FLOATFRAC figures appear after the decimal point.
The total width is again FLOATWIDTH.

In either case if FLOATWIDTH is 0, then only the digits themselves will
be part of the number.  (I.e there will be no leading spaces.)

The printing is also governed by FLOATOPTIONS (default FALSE).  This
may be set to a list of items, which should be any of:
"+"	print + for positive integers
LEFT	place sign in leftmost column instead of by leftmost digit
0	print trailing zeros
E	force E format for fixed precision output
E.g. FLOATOPTIONS:['"+",'E];

If you specify too large a precision, or small a width, then the number
will appear in the default manner.

Currently the Macsyma displayer (the guy that prints D and E lines),
PRINT and CONCAT will use this method of printing floating point numbers.
SAVE, STRING and STRINGOUT do not, so there should be no loss of precision
in doing a SAVE followed by a LOADFILE or a STRINGOUT followed by a
BATCH.

For fuller documentation do :PRINT LIBDOC;FFORMA >
which documents the Fortran-style-FORMAt package (written by JONL), and 
is the support for the formatter herein discussed.
There might be a better user interface provided if there is a consensus
on how it should be done.

Example:
LOADFILE(FORMAT,FASL,DSK,SHARE);
FLOATFORMAT:TRUE;
PI:EV(%PI,NUMER);
 				           3.14
FOR I FROM -10 THRU 10 DO PRINT(10^I*PI);
  3.14E-10 
   3.14E-9 
   3.14E-8 
   3.14E-7 
   3.14E-6 
   3.14E-5 
   3.14E-4 
   0.00314 
    0.0314 
     0.314 
      3.14 
      31.4 
   3.14E+2 
   3.14E+3 
   3.14E+4 
   3.14E+5 
   3.14E+6 
   3.14E+7 
   3.14E+8 
   3.14E+9 
  3.14E+10 
FLOATOPTIONS:['E];
FOR I FROM -10 THRU 10 DO PRINT(10^I*PI);
  3.14E-10 
   3.14E-9 
   3.14E-8 
   3.14E-7 
   3.14E-6 
   3.14E-5 
   3.14E-4 
   3.14E-3 
   3.14E-2 
   3.14E-1 
   3.14E+0 
   3.14E+1 
   3.14E+2 
   3.14E+3 
   3.14E+4 
   3.14E+5 
   3.14E+6 
   3.14E+7 
   3.14E+8 
   3.14E+9 
  3.14E+10 
FLOATFORMAT:'F;
FLOATOPTIONS:FALSE;
FOR I FROM -10 THRU 10 DO PRINT(10^I*PI);
      0.00 
      0.00 
      0.00 
      0.00 
      0.00 
      0.00 
      0.00 
      0.00 
      0.03 
      0.31 
      3.14 
     31.42 
    314.16 
   3141.59 
  31415.93 
 314159.26 
3141592.66 
31415926.5 
3.14159265E+8 
3.14159265E+9 
3.14159265E+10 

Comments etc. to CFFK@MC