Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > e3d62627d1d1aab7ab1be2dd7f65a872 > files > 298

ecl-10.4.1-1.fc14.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>2.3.&#160;Integers</title><link rel="stylesheet" href="ecl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="ch25.html" title="Chapter&#160;2.&#160;Manipulating Lisp objects"><link rel="prev" href="ch25s02.html" title="2.2.&#160;Constructing objects"><link rel="next" href="ch25s04.html" title="2.4.&#160;Characters"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.3.&#160;Integers</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch25s02.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;2.&#160;Manipulating Lisp objects</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch25s04.html">Next</a></td></tr></table><hr></div><div class="section" title="2.3.&#160;Integers"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Internals-Integers"></a>2.3.&#160;Integers</h2></div></div></div><p>Common-Lisp distinguishes two types of integer types: bignums and fixnums. A
  fixnum is a small integer, which ideally occupies only a word of memory and
  which is between the values <em class="replaceable"><code>MOST-NEGATIVE-FIXNUM</code></em> and
  <em class="replaceable"><code>MOST-POSITIVE-FIXNUM</code></em>. A bignum is any integer which is not a fixnum and
  it is only constrained by the amount of memory available to represent it.</p><p>In <span class="application">ECL</span> a fixnum is an integer that, together with the tag bits, fits in a
  word of memory. The size of a word, and thus the size of a fixnum, varies from
  one architecture to another, and you should refer to the types and constants in
  the <code class="filename">ecl.h</code> header to make sure that your C extensions are portable.
  All other integers are stored as bignums, they are not immediate objects, they
  take up a variable amount of memory and the GNU Multiprecision Library is
  required to create, manipulate and calculate with them.</p><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677074"></a>&#8212; C type: <span class="structname">cl_fixnum</span></pre><p>This is a C signed integer type capable of holding a whole fixnum without any
   loss of precision. The opposite is not true, and you may create a
   <code class="literal">cl_fixnum</code> which exceeds the limits of a fixnum and should be stored as a
   bignum.</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677104"></a>&#8212; C type: <span class="structname">cl_index</span></pre><p>This is a C unsigned integer type capable of holding a nonnegative fixnum without
   loss of precision. Typically, a <code class="literal">cl_index</code> is used as an index into an array,
   or into a proper list, etc.</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677134"></a>&#8212; Constant: <code class="varname">MOST_NEGATIVE_FIXNUM</code></pre><pre class="screen"><a class="indexterm" name="id677150"></a>&#8212; Constant: <code class="varname">MOST_POSITIVE_FIXNUM</code></pre><p>These constants mark the limits of a fixnum.</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677173"></a>&#8212; Function: <span class="returnvalue">bool</span> <code class="function">FIXNUM_MINUSP</code> (<span class="type">cl_object</span> <code class="varname">o</code>)</pre><pre class="screen"><a class="indexterm" name="id677202"></a>&#8212; Function: <span class="returnvalue">bool</span> <code class="function">FIXNUM_PLUSP</code> (<span class="type">cl_object</span> <code class="varname">o</code>)</pre><p>These functions perform the checks (<em class="replaceable"><code>o</code></em> &lt; 0) and (0 &lt;= <em class="replaceable"><code>o</code></em>),
   respectively.</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677245"></a>&#8212; Function: <span class="returnvalue">cl_object</span> <code class="function">MAKE_FIXNUM</code> (<span class="type">cl_fixnum</span> <code class="varname">n</code>)</pre><pre class="screen"><a class="indexterm" name="id677274"></a>&#8212; Function: <span class="returnvalue">cl_fixnum</span> <code class="function">fix</code> (<span class="type">cl_object</span> <code class="varname">o</code>)</pre><p><code class="literal">MAKE_FIXNUM</code> and <code class="literal">fix</code> convert from an integer to a lisp object
   of fixnum type and vice versa. These functions no not check their arguments.</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677322"></a>&#8212; Function: <span class="returnvalue">cl_fixnum</span> <code class="function">fixint</code> (<span class="type">cl_object</span> <code class="varname">o</code>)</pre><p>Converts a lisp fixnum to a C integer of the appropriate size. Signals an error
   if <em class="replaceable"><code>o</code></em> is not of fixnum type.</p></blockquote></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id677362"></a>&#8212; Function: <span class="returnvalue">cl_index</span> <code class="function">fixnnint</code> (<span class="type">cl_object</span> <code class="varname">o</code>)</pre><p>Similar to <code class="literal">fixint</code> but also ensures that <em class="replaceable"><code>o</code></em> is not negative.</p></blockquote></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch25s02.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch25.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch25s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.2.&#160;Constructing objects&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;2.4.&#160;Characters</td></tr></table></div></body></html>