srinivasan srinivas wrote:
Yes. But it didn't give only the expected decimals. For ex: >>> a = 1.23 >>> abs(int(a) -a) 0.22999999999999998I would like to get the result '0.23' only.
well, thats what get stored internally - there is no way around it if you are using floating point numbers: >>> 0.23 0.23000000000000001 but str() handles the rounding correctly: >>> print 0.23 0.23 >>> print abs(int(a) -a) 0.23 See also http://en.wikipedia.org/wiki/Floating_point for the problems with FP figures. Regards Tino
smime.p7s
Description: S/MIME Cryptographic Signature
-- http://mail.python.org/mailman/listinfo/python-list