simple float numbers problem

Christopher A. Craig list-python at ccraig.org
Mon Nov 10 09:41:01 EST 2003


"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