GNU Info

Info Node: (librep.info)Numbers

(librep.info)Numbers


Next: Sequences Prev: Data Types Up: The language
Enter node , (file) or (file)node

Numbers
=======

   `Librep' distinguishes between numbers that are represented exactly
and numbers that may not be. This is similar to the Scheme dialect of
Lisp. Quoting from the Scheme standard:

     ... numbers are either _exact_ or _inexact_. A number is exact if
     it was written as an exact constant or was derived from exact
     numbers using only exact operations. A number is inexact if it was
     written as an inexact constant, if it was derived using inexact
     ingredients, or if it was derived using inexact operations. Thus
     inexactness is a contagious property of a number.

   Exact numbers include both integers and rational numbers, there is no
theoretical limit to the range of the values that may be represented
(1). Inexact numbers are currently implemented using double precision
floating point values.

   The read syntax of any number is: `[PFX...][SGN]DATA...', where the
optional SGN is one of the characters `-' or `+', DATA is the
representation of the number, and PFX 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.

   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.

 - Function: numberp object
     Returns true if OBJECT is a number.

Arithmetic Functions
Integer Functions
Rational Functions
Real Number Functions
Mathematical Functions
Bitwise Functions
Numeric Predicates
Random Numbers
Characters
   ---------- Footnotes ----------

   (1) However, depending on implementation restrictions, very large
integers may be coerced to an inexact representation.


automatically generated by info2www version 1.2.2.9