In article <[EMAIL PROTECTED]>, Andy Leszczynski wrote:
> >>> a=1.1
> >>> a
> 1.1000000000000001
> >>>
> 
> 
> Is it normal?

Yes, for floating-point numbers. This is due to inherent imprecision
in how floats are represented in hardware. If you can live with being
a touch off that many decimal places out, you can just clean up upon
printing with something like:

>>>print "%0.1f" % (a)
1.1

for your value of a above. If you don't want to deal with this cruft,
you may want to give the Decimal class a gander:

>>>from Decimal import *
>>>setcontext(ExtendedContext)
>>>a = Decimal('1.1')
>>>a
'Decimal("1.1")'
>>> print a
1.1


-- 
zoerhoff(AT)sdf.lonestar.org 
kristian.zoerhoff(AT)gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to