Debian Codegraph @

src/doc/old-manual/ansi_numbers.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE book [
3 <!ENTITY % eclent SYSTEM "ecl.ent">
4 %eclent;
5 ]>
6 <book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
7 <chapter xml:id="ansi.numbers">
8 <title>Numbers</title>
9
10 <section xml:id="ansi.number-types">
11 <title>Numeric types</title>
12
13 <para>&ECL; supports all of the &CommonLisp; numeric tower, which is shown
14 in <xref linkend="table.ansi.numbers"/>. The details, however, depend both
15 on the platform on which &ECL; runs and on the configuration which was
16 chosen when building &ECL;.</para>
17 <table xml:id="table.ansi.numbers">
18 <title>Numeric types in &ECL;</title>
19 <tgroup cols="2">
20 <thead>
21 <row><entry>Type</entry><entry>Description</entry></row>
22 </thead>
23 <tbody>
24 <row>
25 <entry><type>fixnum</type></entry>
26 <entry>Signed integer with a number of bits given by
27 <varname>ext:fixnum-bits</varname>, fit in a machine word.</entry>
28 </row>
29 <row>
30 <entry><type>bignum</type></entry>
31 <entry>Arbitrary size integers, only limited by amount of memory.</entry>
32 </row>
33 <row>
34 <entry><type>ratio</type></entry>
35 <entry>Arbitrary size rational number, made up of two integers.</entry>
36 </row>
37 <row>
38 <entry><type>short-float</type></entry>
39 <entry>Equivalent to <type>single-float</type>.</entry>
40 </row>
41 <row>
42 <entry><type>single-float</type></entry>
43 <entry>32-bits IEEE floating point number.</entry>
44 </row>
45 <row>
46 <entry><type>double-float</type></entry>
47 <entry>64-bits IEEE floating point number.</entry>
48 </row>
49 <row>
50 <entry><type>long-float</type></entry>
51 <entry>Either equivalent to <type>double-float</type>, or a 96/128 bits IEEE floating
52 point number (<type>long double</type> in C/C++).</entry>
53 </row>
54 <row>
55 <entry><type>rational</type></entry>
56 <entry>An alias for <type>(or integer ratio)</type></entry>
57 </row>
58 <row>
59 <entry><type>float</type></entry>
60 <entry>An alias for <type>(or single-float double-float short-float
61 long-float)</type></entry>
62 </row>
63 <row>
64 <entry><type>real</type></entry>
65 <entry>An alias for <type>(or real integer float)</type></entry>
66 </row>
67 <row>
68 <entry><type>complex</type></entry>
69 <entry>Complex number made of two real numbers of the above mentioned
70 types.</entry>
71 </row>
72 </tbody>
73 </tgroup>
74 </table>
75
76 <para>In general, the size of a <type>FIXNUM</type> is determined by the
77 word size of a machine, which ranges from 32 to 64 bits. Integers larger
78 than this are implemented using the <ulink
79 url="http://www.swox.com/gmp/">GNU Multiprecision library</ulink>. Rationals
80 are implemented using two integers, without caring whether they are fixnum
81 or not. Floating point numbers include at least the two IEEE types of 32 and
82 64 bits respectively. In machines where it is supported, it is possible to
83 associate the lisp <type>LONG-FLOAT</type> with the machine type <type>long
84 double</type> whose size ranges from 96 to 128 bits, and which are a bit
85 slower.</para>
86 </section>
87
88 <section xml:id="ansi.random-states">
89 <title>Random-States</title>
90
91 <para>&ECL; relies internally on a 32-bit <!-- or 64-bit -->
92 Mersenne-Twister random number generator, using a relatively large
93 buffer to precompute about 5000 pseud-random bytes. This implies
94 also that random states can be printed readably and also read, using
95 the <literal>#$</literal> macro. There is no provision to create
96 random states from user arrays, though. Random state is printed
97 unreadably by default.</para>
98 <para>
99 The <literal>#$</literal> macro can be used to initialize
100 generatorr with the random seed (an integer), an array of random
101 bytes (mainly used for reading back printed random-state) and an
102 another random-state (syntactic sugar for copying of the
103 random-state).
104 </para>
105
106 <!-- <programlisting> put examples in txi after conversion-->
107 <!-- #$1234 -> #<random-state 0300c000> -->
108 <!-- (let ((*print-readably* t))
109 (print #$1234)) -> ...-->
110 <!-- (read-from-string (format nil )) -->
111 <!-- </programlisting> -->
112 </section>
113
114 <xi:include href="ref_c_numbers.xml" xpointer="ansi.numbers.c-dict" xmlns:xi="http://www.w3.org/2001/XInclude"/>
115
116 </chapter>
117 </book>