The simplest output functions are those that display numbers from the
data or floating-point stacks. Floating-point output is always displayed
using base 10. Numbers displayed from the data stack use the value stored
.( n – ) core “dot”
Display (the signed single number) n in free-format, followed by a space.
dec.( n – ) gforth-0.4 “dec.”
Display n as a signed decimal number, followed by a space.
hex.( u – ) gforth-0.4 “hex.”
Display u as an unsigned hex number, prefixed with a "$" and followed by a space.
u.( u – ) core “u-dot”
Display (the unsigned single number) u in free-format, followed by a space.
.r( n1 n2 – ) core-ext “dot-r”
Display n1 right-aligned in a field n2 characters wide. If more than n2 characters are needed to display the number, all digits are displayed. If appropriate, n2 must include a character for a leading “-”.
u.r( u n – ) core-ext “u-dot-r”
Display u right-aligned in a field n characters wide. If more than n characters are needed to display the number, all digits are displayed.
d.( d – ) double “d-dot”
Display (the signed double number) d in free-format. followed by a space.
ud.( ud – ) gforth-0.4 “u-d-dot”
Display (the signed double number) ud in free-format, followed by a space.
d.r( d n – ) double “d-dot-r”
Display d right-aligned in a field n characters wide. If more than n characters are needed to display the number, all digits are displayed. If appropriate, n must include a character for a leading “-”.
ud.r( ud n – ) gforth-0.4 “u-d-dot-r”
Display ud right-aligned in a field n characters wide. If more than n characters are needed to display the number, all digits are displayed.
f.( r – ) float-ext “f-dot”
Display (the floating-point number) r without exponent, followed by a space.
fe.( r – ) float-ext “f-e-dot”
Display r using engineering notation (with exponent dividable by 3), followed by a space.
fs.( r – ) gforth-0.4 “f-s-dot”
Display r using scientific notation (with exponent), followed by a space.
fp.( r – ) float-ext “f-e-dot”
Display r using SI prefix notation (with exponent dividable by 3, converted into SI prefixes if available), followed by a space.
Examples of printing the number 1234.5678E23 in the different floating-point output formats are shown below.
f. 123456780000000000000000000. fe. 123.456780000000E24 fs. 1.23456780000000E26 fp. 123.456780000000Y
precision( – u ) float-ext “precision”
u is the number of significant digits currently used by
set-precision( u – ) float-ext “set-precision”
Set the number of significant digits currently used by
FS. to u.
f.rdp( rf +nr +nd +np – ) gforth-0.6 “f.rdp”
Print float rf formatted. The total width of the output is
nr. For fixed-point notation, the number of digits after the
decimal point is +nd and the minimum number of significant
digits is np.
Set-precision has no effect on
f.rdp. Fixed-point notation is used if the number of
siginicant digits would be at least np and if the number of
digits before the decimal point would fit. If fixed-point notation
is not used, exponential notation is used, and if that does not
fit, asterisks are printed. We recommend using nr>=7 to avoid
the risk of numbers not fitting at all. We recommend
nr>=np+5 to avoid cases where
f.rdp switches to
exponential notation because fixed-point notation would have too
few significant digits, yet exponential notation offers fewer
significant digits. We recommend nr>=nd+2, if you want to
have fixed-point notation for some numbers; the smaller the value
of np, the more cases are shown in fixed-point notation (cases
where few or no significant digits remain in fixed-point notation).
We recommend np>nr, if you want to have exponential
notation for all numbers.
f.rdp the output depends on the parameters. To give you a
better intuition of how they influence the output, here are some
examples of parameter combinations; in each line the same number is
printed, in each column the same parameter combination is used for
12 13 0 7 3 4 7 3 0 7 3 1 7 5 1 7 7 1 7 0 2 4 2 1 |-1.234568E-6|-1.2E-6| -0.000|-1.2E-6|-1.2E-6|-1.2E-6|-1.2E-6|****| |-1.234568E-5|-1.2E-5| -0.000|-1.2E-5|-.00001|-1.2E-5|-1.2E-5|****| |-1.234568E-4|-1.2E-4| -0.000|-1.2E-4|-.00012|-1.2E-4|-1.2E-4|****| |-1.234568E-3|-1.2E-3| -0.001| -0.001|-.00123|-1.2E-3|-1.2E-3|****| |-1.234568E-2|-1.2E-2| -0.012| -0.012|-.01235|-1.2E-2|-1.2E-2|-.01| |-1.234568E-1|-1.2E-1| -0.123| -0.123|-.12346|-1.2E-1|-1.2E-1|-.12| |-1.2345679E0| -1.235| -1.235| -1.235|-1.23E0|-1.23E0|-1.23E0|-1E0| |-1.2345679E1|-12.346|-12.346|-12.346|-1.23E1|-1.23E1| -12.|-1E1| |-1.2345679E2|-1.23E2|-1.23E2|-1.23E2|-1.23E2|-1.23E2| -123.|-1E2| |-1.2345679E3|-1.23E3|-1.23E3|-1.23E3|-1.23E3|-1.23E3| -1235.|-1E3| |-1.2345679E4|-1.23E4|-1.23E4|-1.23E4|-1.23E4|-1.23E4|-12346.|-1E4| |-1.2345679E5|-1.23E5|-1.23E5|-1.23E5|-1.23E5|-1.23E5|-1.23E5|-1E5|