Remove integer from float number
Michael Yanowitz
m.yanowitz at kearfott.com
Thu Mar 23 17:21:06 EST 2006
how about this solution:
def printDecimal(number):
if (number < 0):
print number - int(number)
else:
print int(number) - number
-----Original Message-----
From: python-list-bounces+m.yanowitz=kearfott.com at python.org
[mailto:python-list-bounces+m.yanowitz=kearfott.com at python.org]On Behalf
Of Grant Edwards
Sent: Thursday, March 23, 2006 5:11 PM
To: python-list at python.org
Subject: Re: Remove integer from float number
On 2006-03-23, Arne Ludwig <arne at citde.net> wrote:
> With that terse description and the subject line I would interpret the
> OP like so:
>
>>>> print re.sub(".*\.",".","0.666")
> .666
>>>> print re.sub(".*\.",".","123.666")
> .666
Or if you're allergic to regular expressions:
>>> print "." + "0.666".split(".")[-1]
.666
>>> print "." + "123.666".split(".")[-1]
.666
>>>
--
Grant Edwards grante Yow! Yow! It's a hole
at all the way to downtown
visi.com Burbank!
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list