The next arg is printed as a float.
The full form is ~
w,
d,
k,
overflowchar,
padcharF
.
The parameter w
is the width of the field to be printed; d is the number
of digits to print after the decimal point; k is a scale factor
that defaults to zero.
Exactly w characters will
be output. First, leading copies of the character padchar
(which defaults to a space) are printed, if necessary, to pad the
field on the left.
If the arg is negative, then a minus sign is printed;
if the arg is not negative, then a plus sign is printed
if and only if the @
modifier was supplied. Then a sequence
of digits, containing a single embedded decimal point, is printed;
this represents the magnitude of the value of arg times 10^k,
rounded to d fractional digits.
When rounding up and rounding down would produce printed values
equidistant from the scaled value of arg, then the implementation
is free to use either one. For example, printing the argument
6.375
using the format ~4,2F
may correctly produce
either 6.37
or 6.38
.
Leading zeros are not permitted, except that a single
zero digit is output before the decimal point if the printed value
is less than one, and this single zero digit is not output
at all if w=d+1.
If it is impossible to print the value in the required format in a field of width w, then one of two actions is taken. If the parameter overflowchar is supplied, then w copies of that parameter are printed instead of the scaled value of arg. If the overflowchar parameter is omitted, then the scaled value is printed using more than w characters, as many more as may be needed.
If the w parameter is omitted, then the field is of variable width.
In effect, a value is chosen
for w in such a way that no leading pad characters need to be printed
and exactly d characters will follow the decimal point.
For example, the directive ~,2F
will print exactly
two digits after the decimal point and as many as necessary before the
decimal point.
If the parameter d is omitted, then there is no constraint on the number of digits to appear after the decimal point. A value is chosen for d in such a way that as many digits as possible may be printed subject to the width constraint imposed by the parameter w and the constraint that no trailing zero digits may appear in the fraction, except that if the fraction to be printed is zero, then a single zero digit should appear after the decimal point if permitted by the width constraint.
If both w and d are omitted, then the effect is to print
the value using ordinary free-format output; prin1
uses this format
for any number whose magnitude is either zero or between
10^-3 (inclusive) and 10^7 (exclusive).
If w is omitted, then if the magnitude of arg is so large (or, if
d is also omitted, so small) that more than 100 digits would have to
be printed, then an implementation is free, at its discretion, to print
the number using exponential notation instead, as if by the directive
~E
(with all parameters to ~E
defaulted, not
taking their values from the ~F
directive).
If arg is a rational
number, then it is coerced to be a single float
and then printed. Alternatively, an implementation is permitted to
process a rational
number by any other method that has essentially the
same behavior but avoids loss of precision or overflow
because of the coercion. If w and d are
not supplied and the number has no exact decimal representation,
for example 1/3
, some precision cutoff must be chosen
by the implementation since only a finite number of digits may be printed.
If arg is a complex number or some non-numeric
object,
then it is printed using the format directive ~
wD
,
thereby printing it in decimal radix and a minimum field width of w.
~F
binds
*print-escape*
to false
and *print-readably*
to false.
The next arg is printed as a float in exponential notation.
The full form is
~
w,
d,
e,
k,
overflowchar,
padchar,
exponentcharE
.
The parameter w
is the width of the field to be printed; d is the number
of digits to print after the decimal point; e is the number
of digits to use when printing the exponent;
k is a scale factor that defaults to one (not zero).
Exactly w characters will
be output. First, leading copies of the character padchar
(which defaults to a space) are printed, if necessary, to pad the
field on the left.
If the arg is negative, then a minus sign is printed;
if the arg is not negative, then a plus sign is printed
if and only if the @
modifier was supplied. Then a sequence
of digits containing a single embedded decimal point is printed.
The form of this sequence of digits depends on the scale factor k.
If k is zero, then d digits are printed after the decimal
point, and a single zero digit appears before the decimal point if
the total field width will permit it. If k is positive,
then it must be strictly less than d+2; k significant digits
are printed before the decimal point, and d− k+1
digits are printed after the decimal point. If k is negative,
then it must be strictly greater than − d;
a single zero digit appears before the decimal point if
the total field width will permit it, and after the decimal point
are printed first
− k zeros and then d+k significant digits.
The printed fraction must be properly rounded.
When rounding up and rounding down would produce printed values
equidistant from the scaled value of arg, then the implementation
is free to use either one. For example, printing the argument
637.5
using the format ~8,2E
may correctly produce
either 6.37E+2
or 6.38E+2
.
Following the digit sequence, the exponent is printed.
First the character parameter exponentchar is printed; if this
parameter is omitted, then the exponent marker that
prin1
would use is printed, as determined from the
type of the float and the current value of
*read-default-float-format*
.
Next, either a plus sign or a minus sign
is printed, followed by e digits representing the power of
ten by which the printed fraction must be multiplied
to properly represent the rounded value of arg.
If it is impossible to print the value in the required format in a field of width w, possibly because k is too large or too small or because the exponent cannot be printed in e character positions, then one of two actions is taken. If the parameter overflowchar is supplied, then w copies of that parameter are printed instead of the scaled value of arg. If the overflowchar parameter is omitted, then the scaled value is printed using more than w characters, as many more as may be needed; if the problem is that d is too small for the supplied k or that e is too small, then a larger value is used for d or e as may be needed.
If the w parameter is omitted, then the field is of variable width. In effect a value is chosen for w in such a way that no leading pad characters need to be printed.
If the parameter d is omitted, then there is no constraint on the number of digits to appear. A value is chosen for d in such a way that as many digits as possible may be printed subject to the width constraint imposed by the parameter w, the constraint of the scale factor k, and the constraint that no trailing zero digits may appear in the fraction, except that if the fraction to be printed is zero then a single zero digit should appear after the decimal point.
If the parameter e is omitted, then the exponent is printed using the smallest number of digits necessary to represent its value.
If all of w, d, and e are omitted, then the effect is to print
the value using ordinary free-format exponential-notation output;
prin1
uses
a similar
format for any non-zero number whose magnitude
is less than 10^-3 or greater than or equal to 10^7.
The only difference is that the ~E
directive always prints a plus or minus sign in front of the
exponent, while prin1
omits the plus sign if the exponent is
non-negative.
If arg is a rational
number, then it is coerced to be a single float
and then printed. Alternatively, an implementation is permitted to
process a rational
number by any other method that has essentially the
same behavior but avoids loss of precision or overflow
because of the coercion. If w and d are
unsupplied and the number has no exact decimal representation,
for example 1/3
, some precision cutoff must be chosen
by the implementation since only a finite number of digits may be printed.
If arg is a complex number or some non-numeric
object,
then it is printed using the format directive ~
wD
,
thereby printing it in decimal radix and a minimum field width of w.
~E
binds
*print-escape*
to false
and *print-readably*
to false.
The next arg is printed as a float in either fixed-format or exponential notation as appropriate.
The full form is ~
w,
d,
e,
k,
overflowchar,
padchar,
exponentcharG
.
The format in which to print arg depends on the magnitude (absolute
value) of the arg. Let n be an integer such that
10^n-1 ≤ |arg| < 10^n.
Let ee equal e+2, or 4 if e is omitted.
Let ww equal w− ee,
or nil
if w is omitted. If d is omitted, first let q
be the number of digits needed to print arg with no loss
of information and without leading or trailing zeros;
then let d equal (max
q (min
n 7))
.
Let dd equal d− n.
If 0 ≤ dd ≤ d, then arg is printed as if by the format directives
~
ww,
dd,,
overflowchar,
padcharF~
ee@T
Note that the scale factor k is not passed to the ~F
directive. For all other values of dd, arg is printed as if
by the format directive
~
w,
d,
e,
k,
overflowchar,
padchar,
exponentcharE
In either case, an @
modifier is supplied to the ~F
or ~E
directive if and only if one was supplied to the
~G
directive.
~G
binds
*print-escape*
to false
and *print-readably*
to false.
The next arg is printed as a float in fixed-format notation.
The full form is ~
d,
n,
w,
padchar$
.
The parameter d is the number
of digits to print after the decimal point (default value 2);
n is the minimum number of digits to print before the decimal
point (default value 1);
w is the minimum total width of the field to be printed (default
value 0).
First padding and the sign are output.
If the arg is negative, then a minus sign is printed;
if the arg is not negative, then a plus sign is printed
if and only if the @
modifier was supplied.
If the :
modifier is used, the sign appears before any padding,
and otherwise after the padding.
If w is supplied and the number of other characters to be output
is less than w, then copies of padchar (which defaults
to a space) are output to
make the total field width equal w.
Then n digits are printed for the integer part of arg,
with leading zeros if necessary; then a decimal point;
then d digits of fraction, properly rounded.
If the magnitude of arg is so large that more than m digits would
have to be printed, where m is the larger of w and 100, then an
implementation is free, at its discretion, to print the number using
exponential notation instead, as if by the directive
~
w,
q,,,,
padcharE
, where w and padchar are
present or omitted according to whether they were present or omitted in
the ~$
directive, and where q=d+n− 1,
where d and n are the (possibly default) values given to the
~$
directive.
If arg is a rational number, then it is coerced to be a single float and then printed. Alternatively, an implementation is permitted to process a rational number by any other method that has essentially the same behavior but avoids loss of precision or overflow because of the coercion.
If arg is a complex number or some non-numeric
object,
then it is printed using the format directive ~
wD
,
thereby printing it in decimal radix and a minimum field width of w.
~$
binds *print-escape*
to false
and *print-readably*
to false.