simple float numbers problem

Ladvánszky Károly aa at bb.cc
Mon Nov 10 19:25:57 CET 2003


I'm running CLISP.
(type-of 25.99) gives SINGLE-FLOAT
(type-of  (+ 10 15.99)) gives SINGLE-FLOAT
I'm going to post it on the List group to see what Lispers say about it.
By the way, Smalltalk also gives the right answer.

"Christopher A. Craig" <list-python at ccraig.org> az alábbiakat írta a
következo hírüzenetben: mailman.602.1068475270.702.python-list at python.org...
> "Ladvánszky Károly" <aa at bb.cc> writes:
>
> > Lisp does the right thing:
> > (= (+ 10 15.99) 25.99)
> > T
> >
> > Does Lisp not use the math processor?
>
> I don't know which Lisp you're speaking of here, but chances are very
> good that 15.99 is not a float in this particular lisp.  I'd guess
> it's probably rational.  You can do that with Python if you get a
> rational library such as the one I mentioned in my previous post to
> this thread.  The problem is that rationals are notoriously slow.  If
> you tried to implement
>
> a = 0
> for i in range(1,5000):
>   a += 1./i
>
> in this lisp, and I'm right, it should take longer than Python (but
> will give the "right" answer instead of Python's approximate one)
>
> --
> Christopher A. Craig <list-python at ccraig.org>
> "The mistakes made by Congress wouldn't be so bad if the next Congress
> didn't keep trying to correct them." Cullen Hightower
>
>






More information about the Python-list mailing list