[Nickle] BigInteger bug
bart at po8.org
Mon Feb 27 23:19:32 PST 2006
Interesting bug report! This is one of the uglier Nickle
bugs in quite a long time.
Unfortunately, I can't reproduce the bug from CVS head.
Also, I tried building CVS head from scratch on my home
Linux box, and it seems to build fine.
I'm afraid we'll need a bit more information so we can track
down and solve your problem. Exactly what version of the
Nickle source were you using, obtained from where? What
operating system? What CPU? What specific build problem
did you have? Can you supply a script that will reproduce
the bug reliably? In particular, is the invocation of fib()
necessary, or does just typing in the last sum fail (I'd
expect the latter)?
Let us know and we'll track this down and fix it for you.
P.S.---BTW, it's not terribly relevant and I'm sure you know this,
but the normal way to code what you were doing would be to
use nested functions to hide the utility function fibh()...
int fib (int n)
int fibh (int n, int a, int b)
if (0 == n)
return fibh (n - 1, b, a + b);
return fibh (n, 1, 1);
In message <883cfe6d0602271947k69cdcecet424f216146320063 at mail.gmail.com> you wrote:
> So I do realize that the code from CVS HEAD is canonical, but it's
> currently in a non-building state.. I thus can't verify whether this
> works in recent CVS builds or not.
> As seen from the code below, it seems that the conversion from integer
> to big integer is not done at the right spot, and given two
> sufficiently large numbers the sum is negative.
> > print fib
> int fib (int n)
> return fibh (n, 1, 1);
> > print fibh
> int fibh (int n, int a, int b)
> if (0 == n)
> return a;
> return fibh (n - 1, b, a + b);
> > fib(42)
> > fib(43)
> > 4334944370
> > 4334944370 + 701408733
> > 433494437 + 701408733
> Michel Salim
> Nickle mailing list
> Nickle at nickle.org
More information about the Nickle