<div dir="ltr">Thank you.<div><br></div><div style>Actually, I've just watched Marc's video about the 90-mins scheme to C compiler and I feel more ready to at least open gambit's implementation files. Is something I feared doing, but I see that is fundamental to understand this sort of stuff.</div>

<div style><br></div><div style>Your explanation clarifies a couple of misconceptions I had on fixnums.</div><div style><br></div><div style>Best regards,</div><div style><br></div><div style>Álvaro</div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Fri, Dec 28, 2012 at 5:53 PM, Bradley Lucier <span dir="ltr"><<a href="mailto:lucier@math.purdue.edu" target="_blank">lucier@math.purdue.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word">I don't know what internal model you have of Gambit's numbers, but here's a block comment in _num#.scm that explains some of the relationships between Gambit's number representations.<br>

<br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">;;;============================================================================<br>;;; Number representation.<br>;; There are 5 internal representations for numbers:<br>

;;<br>;; fixnum, bignum, ratnum, flonum, cpxnum<br>;;<br>;; Fixnums and bignums form the class of exact-int.<br>;; Fixnums, bignums and ratnums form the class of exact-real.<br>;; Fixnums, bignums, ratnums and flonums form the class of noncpxnum.<br>

;; The representation has some invariants:<br>;;<br>;; The numerator of a ratnum is a non-zero exact-int.<br>;; The denominator of a ratnum is an exact-int greater than 1.<br>;; The numerator and denominator have no common divisors greater than 1.<br>

;;<br>;; The real part of a cpxnum is a noncpxnum.<br>;; The imaginary part of a cpxnum is a noncpxnum != fixnum 0<br>;; The following table gives the mapping of the Scheme exact numbers to their<br>;; internal representation:<br>

;;<br>;;    type          representation<br>;; exact integer  = exact-int (fixnum, bignum)<br>;; exact rational = exact-real (fixnum, bignum, ratnum)<br>;; exact real     = exact-real (fixnum, bignum, ratnum)<br>;; exact complex  = exact-real or cpxnum with exact-real real and imag parts<br>

;; For inexact numbers, the representation is not quite as straightforward.<br>;;<br>;; There are 3 special classes of inexact representation:<br>;; flonum-int : flonum with integer value<br>;; cpxnum-real: cpxnum with imag part = flonum 0.0 or -0.0<br>

;; cpxnum-int : cpxnum-real with exact-int or flonum-int real part<br>;;<br>;; Note: cpxnum-real and cpxnum-int only exist if<br>;; (macro-cpxnum-are-possibly-real?) returns #t.<br>;;<br>;; This gives the following table for Scheme's inexact numbers:<br>

;;<br>;;      type          representation<br>;; inexact integer  = flonum-int or cpxnum-int if it exists<br>;; inexact rational = flonum     or cpxnum-real if it exists<br>;; inexact real     = flonum     or cpxnum-real if it exists<br>

;; inexact complex  = flonum     or cpxnum with flonum real or imag part</blockquote><br>The maximum and minimum fixnums can be queried; for example, in a 64-bit implementation:<br><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

> ##max-fixnum<br>2305843009213693951<br>> ##min-fixnum<br>-2305843009213693952</blockquote><br>Exact integers outside this range are bignums.  Bignums are limited in size based on how big an individual object can be in Gambit (about (expt 2 24) bytes in a 32-bit implementation and (expt 2 56) bytes (i.e., basically unlimited) in a 64-bit implementation).<br>

<br>Inexact numbers are the same as C doubles (64-bit).  Extended precision floating-point numbers (80-bit numbers) are used in extremis on machines that do not support 64-bit floating-point numbers natively.  (Don't ask.)<br>

<br>fx operations expect fixnum operands and yield fixnum results, fl operations expect flonum operands and yield flonum results.  Code compiled with "safe" declarations (the default) check these assumptions and throw an error if they fail; code compiled with "not safe" declarations do not make these checks and can yield incorrect results or crash the program if these assumptions are violated.<div>

<br></div><div>Brad</div></div></blockquote></div><br></div>