This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bignum arithmetics


> From: Mikael Djurfeldt <mdj@nada.kth.se>
> 
> Aleksandar Bakic <bakicale@cse.msu.edu> writes:
> 
> > I ran a function to compute factorial of 10000 in Guile, and got a
> > result that did not end with a zero (it had a bunch of zeros in the
> > middle, but had about a dozen of non-zero digits in the end). What
> > could be the reason?
> 
> At any rate, I don't think it's likely that this is a Guile bug.
> 
> How does your program look like?
> 

Did you try it?  I used the following program.
(define (fact n)
  (let mul ((k 1)(p 1))
    (if (> k n) p (mul (+ k 1)(* k p)))))
after testing with (fact 4) and (fact 5), I tried
(fact 10000) and got something ending in
000000000000000000000000000000000000000004617333575079170156
guile> (version)
"1.3a"
~/downloads$ls -l `which guile`   
-rwxr-xr-x   1 root     root        14412 Jul 14 21:25 /usr/local/bin/guile
So I am using a rather old version.

I remember a discussion of exactly this bug a year or two ago,
with embarassingly long thread devoted to the question of
whether the result _should_ end in zeroes (trust me, it should).
I think somebody had claimed to have fixed it, and that I
believed them at the time.  The problem had to do with an out
of storage condition that was ignored, so if you have too
much RAM maybe it doesn't happen until the number gets
even bigger.  (I have 16M)

-- 
     --Keith

This mail message sent by GNU emacs and Linux.
Food, Shelter, Source code.