Getting fractional part from a float without using string operations
Blind Anagram
nobody at nowhere.org
Wed Nov 19 11:38:15 EST 2008
"MRAB" <google at mrabarnett.plus.com> wrote in message
news:278930e8-6c65-4059-9dec-713e4ba5b554 at w1g2000prk.googlegroups.com...
On Nov 19, 1:44 pm, John Machin <sjmac... at lexicon.net> wrote:
> On Nov 20, 12:35 am, srinivasan srinivas <sri_anna... at yahoo.co.in>
> wrote:
> <null>
>
> | >>> import math
> | >>> num = 123.4567
> | >>> math.modf(num)
> | (0.45669999999999789, 123.0)
def frac(n):
return n - int(n)
n % 1.0
More information about the Python-list
mailing list