[EMAIL PROTECTED] wrote:
> I've never had any call to use floating point numbers and now that I
> want to, I can't!
> 
> *** Python 2.5.1 (r251:54863, May  1 2007, 17:47:05) [MSC v.1310 32
> bit (Intel)] on win32. ***
>>>> float (.3)
> 0.29999999999999999
>>>> foo = 0.3
>>>> foo
> 0.29999999999999999

A classic (if lengthy) read:
http://docs.sun.com/source/806-3568/ncg_goldberg.html

If you just want to see a pretty representation:

     >>> print 0.3
     0.3

If you need a pretty string for use in code:

     >>> def pretty_fp(fpnum, prec=8):
     ...     return ('%.8f' % fpnum).rstrip('0')
     ...
     >>> pretty_fp(0.3)
     '0.3'


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to