A real is constructed directly from a corresponding numeric token; see Figure 2.9.
A complex is notated as a #C
(or #c
) followed by a list
of two reals; see Section 2.4.8.11 (Sharpsign C).
The reader macros #B
, #O
, #X
, and #R
may also be useful
in controlling the input radix in which rationals are parsed;
see Section 2.4.8.7 (Sharpsign B),
Section 2.4.8.8 (Sharpsign O),
Section 2.4.8.9 (Sharpsign X),
and Section 2.4.8.10 (Sharpsign R).
This section summarizes the full syntax for numbers.
Integers can be written as a sequence of digits,
optionally preceded by a sign and optionally followed by a decimal point;
see Figure 2.9.
When a decimal point is used,
the digits are taken to be in radix 10
;
when no decimal point is used,
the digits are taken to be in radix given by the current input base.
For information on how integers are printed, see Section 22.1.3.1.1 (Printing Integers).
Ratios can be written as an optional sign followed by two non-empty sequences of digits separated by a slash; see Figure 2.9. The second sequence may not consist entirely of zeros. Examples of ratios are in the next figure.
|
Figure 2.13: Examples of Ratios
For information on how ratios are printed, see Section 22.1.3.1.2 (Printing Ratios).
Floats can be written in either decimal fraction or computerized
scientific notation: an optional sign, then a non-empty sequence of digits
with an embedded decimal point,
then an optional decimal exponent specification.
If there is no exponent specifier, then
the decimal point is required, and there must be digits
after it.
The exponent specifier consists of an exponent marker,
an optional sign, and a non-empty sequence of digits.
If no exponent specifier is present, or if the exponent marker e
(or E
) is used, then
the format specified
by *read-default-float-format*
is used.
See Figure 2.9.
An implementation may provide one or more kinds of float
that collectively make up the type float
.
The letters s
, f
, d
, and l
(or their
respective uppercase equivalents) explicitly specify the
use of the types short-float
, single-float
,
double-float
, and long-float
, respectively.
The internal format used for an external representation depends only on the exponent marker, and not on the number of decimal digits in the external representation.
The next figure contains examples of notations for floats:
|
Figure 2.14: Examples of Floating-point numbers
For information on how floats are printed, see Section 22.1.3.1.3 (Printing Floats).
A complex has a Cartesian structure, with a real part and an imaginary part each of which is a real. The parts of a complex are not necessarily floats but both parts must be of the same type:
either both are rationals, or both are of the same float subtype.
When constructing a complex, if the specified parts are not the
same type, the parts are converted to be the same type
internally (i.e., the rational part is converted to a float).
An object of type (complex rational)
is converted internally
and represented thereafter as a rational if its imaginary part is an
integer whose value is 0.
For further information, see Section 2.4.8.11 (Sharpsign C) and Section 22.1.3.1.4 (Printing Complexes).