Remove integer from float number

Grant Edwards grante at visi.com
Thu Mar 23 23:29:58 CET 2006


On 2006-03-23, Michael Yanowitz <m.yanowitz at kearfott.com> wrote:

> Sorry, got it backwards:
> def printDecimal(number):
>     if (number >= 0):
> 	  print number - int(number)
>     else:
> 	  print int(number) - number

Still top posted and still doesn't work:

>>> def printDecimal(number):
...     if (number >= 0):
...           print number - int(number)
...     else:
...           print int(number) - number
... 
>>> printDecimal(0.666)
0.666
>>> printDecimal(-0.666)
0.666
>>> 

-- 
Grant Edwards                   grante             Yow!  How many retired
                                  at               bricklayers from FLORIDA
                               visi.com            are out purchasing PENCIL
                                                   SHARPENERS right NOW??



More information about the Python-list mailing list