[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] newbie question about numbers
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] newbie question about numbers |
Date: |
Sun, 7 Feb 2010 23:24:30 +0100 |
User-agent: |
Mutt/1.4.2.3i |
On Sun, Feb 07, 2010 at 03:50:09PM -0300, Hugo Arregui wrote:
> Hi,
>
> I'm new in scheme, and, of course, in chicken too.
Hi and welcome!
> I've a few newbie doubts about numbers, I hope you can help me.
>
> First, reading the scheme report I notice about a set of complex
> numbers procedures:
>
> make-rectangular
> make-polar
> real-part
> etc
>
> I found some of them implemented in chicken (without extensions), but
> miss others. Specifically: make procedures. It's sound very strange to
> me.
Like R5RS says:
"Implementations of Scheme are not required to implement the whole
tower of subtypes given in section 6.2.1, but they must implement
a coherent subset consistent with both the purposes of the
implementation and the spirit of the Scheme language."
In the FAQ there is a rationale for why Chicken does not support the
full numeric tower by default. In short, you can load the "numbers"
egg to get the full numeric tower.
> In other hand, I've doubts about number representations and exactness:
>
> Can I represent a big integer as an exact number?
>
> For example, when I try "#e2000000000", I get this error:
> (inexact->exact) inexact number cannot be represented as an exact
> number: 2000000000.0
After loading numbers, this error goes away and Chicken will behave as
you expect.
> In the Scheme revision I read: "For this purpose, numerical constants
> may be written with an exponent marker that indicates the desired
> precision of the inexact representation. The letters s, f, d, and l
> specify the use of short, single, double, and long precision,
> respectively.". Are these representations available in chicken?
Chicken distinguishes between fixnums and flonums. fixnums are numbers
representable by your computer's architecture, with one bit taken off
for tagging. So on 32 bit that would be -2^31 through +(2^32 - 1).
flonums are numbers representable by your machine's "double". This is
a number in IEEE floating point format which is quite complex :)
The upshot of all this is that flonums can represent bigger numbers
(even integral ones) than fixnums, so Chicken will fall back to using
flonums when numbers you give it don't fit in a fixnum.
I hope this explains it a bit!
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
- [Chicken-users] newbie question about numbers, Hugo Arregui, 2010/02/07
- Re: [Chicken-users] newbie question about numbers,
Peter Bex <=
- Re: [Chicken-users] newbie question about numbers, Peter Bex, 2010/02/07
- Re: [Chicken-users] newbie question about numbers, Hugo Arregui, 2010/02/09
- Re: [Chicken-users] newbie question about numbers, Hugo Arregui, 2010/02/17
- Re: [Chicken-users] newbie question about numbers, John Cowan, 2010/02/17
- Re: [Chicken-users] newbie question about numbers, Kon Lovett, 2010/02/17
- Message not available
- Message not available
- Re: [Chicken-users] newbie question about numbers, Hugo Arregui, 2010/02/18
- Re: [Chicken-users] newbie question about numbers, Hugo Arregui, 2010/02/18