Next: Arithmetic Functions, Previous: Numeric Predicates, Up: Numbers [Contents][Index]

The read syntax of any number is:
`[`

, where the
optional `prefix`…][`sgn`]`data`…`sgn` is one of the characters ‘`-`’ or ‘`+`’,
`data` is the representation of the number, and `prefix` is zero
or more of the following prefix strings:

`#b`

`#B`

Integers are described in binary,

`#o`

`#O`

Integers are in octal,

`#d`

`#D`

Integers are in decimal (the default),

`#x`

`#X`

Integers are in hexadecimal,

`#e`

`#E`

Coerce the number to an exact representation after parsing it,

`#i`

`#I`

Coerce to an inexact representation.

The representation of an integer is simply the digits representing that
integer, in the radix chosen by any given prefix (defaults to decimal).
Examples of valid integer read syntaxes for the number 42 could be
‘`42`’, ‘`#x2a`’, ‘`#o52`’, ‘`#o+52`’, …

The representation of a rational number is two sequences of digits,
separated by a ‘`/`’ character. For example, ‘`3/2`’ represents
the rational number three divided by two. It is supported without gmp too,
but the read value is converted to float.

Inexact numbers are parsed from one of two representations: decimal
point form, which is simply a decimal number containing a decimal
point, and exponential form, which is a decimal number followed by the
letter ‘`e`’ and a decimal exponent multiplying the first part of
the number by that power of ten. For example, ‘`10.0`’, ‘`10.`’
and ‘`1e1`’ all read as the inexact number ten. Note that the radix
prefixes currently have no effect when parsing inexact numbers, decimal
is used exclusively.

An integer’s printed representation is simply the number printed in
decimal with a preceding minus sign if it is negative. Rational numbers
are printed as two integers separated by a ‘`/`’ character. Inexact
numbers are printed in their decimal form.

Next: Arithmetic Functions, Previous: Numeric Predicates, Up: Numbers [Contents][Index]