Getting fractional part from a float without using string operations
srinivasan srinivas
sri_annauni at yahoo.co.in
Wed Nov 19 08:48:55 EST 2008
Yes. But it didn't give only the expected decimals.
For ex:
>>> a = 1.23
>>> abs(int(a) -a)
0.22999999999999998
I would like to get the result '0.23' only.
Thanks,
Srini
________________________________
From: Jeremiah Dodds <jeremiah.dodds at gmail.com>
To: python-list at python.org
Sent: Wednesday, 19 November, 2008 7:14:17 PM
Subject: Re: Getting fractional part from a float without using string operations
On Wed, Nov 19, 2008 at 8:35 AM, srinivasan srinivas <sri_annauni at yahoo.co.in> wrote:
Thanks,
Srini
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
--
http://mail.python.org/mailman/listinfo/python-list
x = 2.99340584
y = abs(int(x) - x)
y
0.99340584
Is that what you wanted?
Get perfect Email ID for your Resume. Grab now http://in.promos.yahoo.com/address
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081119/08f61b02/attachment-0001.html>
More information about the Python-list
mailing list