Menu

#10 numerical computation bug ?

closed
None
5
2004-05-20
2003-03-03
Anonymous
No

I am new to scheme and was playing around
with Jscheme to get started.

> (define (square x) (* x x))
{jsint.Closure square[1] (x)}
> (square (square (square (square 5))))
-2030932031

I get a negative quantity !

However I should get 152587890625 (both
Kawa and my cheap casio calculator give me
this value correctly).

Discussion

  • Timothy John Hickey

    Logged In: YES
    user_id=17797

    The problem is that you are using integers which have a
    fixed size of
    32 bigs, once you get over about 2 billion (2^32) it
    switches to
    negative numbers. This is a Java phenomenon, you can get
    around it
    using floating point numbers
    (square (square (square (square 5.0))))

    We generally use the mailing lists for bug reporting and the
    bugs reported here were supposed to go there, but they haven't
    so we have a years worth of unseen bug reports. Sorry....

    Next time try jscheme-users@sourceforge.net ....

     
  • Timothy John Hickey

    • assigned_to: nobody --> timhickey
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB