chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Possible numbers bug


From: Peter Bex
Subject: Re: [Chicken-users] Possible numbers bug
Date: Wed, 1 Jun 2011 09:51:55 +0200
User-agent: Mutt/1.4.2.3i

On Sun, May 29, 2011 at 11:39:31PM +0200, Peter Bex wrote:
> On Fri, May 27, 2011 at 10:58:04AM +0200, Dominic Pearson wrote:
> > Hello folks,
> > 
> > I am trying to compute the sum i = 0 to n where n = 1000 of n^n, but
> > chicken seems to return the incorrect answer.
> > 
> > http://paste.call-cc.org/paste?id=e0884580a684d1220f3dedb819f63201b6f5eb1a
> > 
> > Racket and scheme48 both seem to give different answers too.
> 
> I figured out where it goes wrong.  expt calls the base Chicken expt and
> if that returns a fixnum, this result is used (if it's a flonum it might've
> overflowed and is inexact anyway so it will use a different path).
> 
> This algorithm is sound.

No, it's not.  The pow() function in C doesn't set errno when it drops
some digits so there's apparently no way to detect this.

I've ripped out the expt code and it now uses the same path for bignums
and fixnums.  This has been released as version 2.5 of the numbers egg.

Thanks for reporting this!

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]