how to calculate the decimal part

fpart *=  2

if fpart >=1
        s.append("1")
        fpart -= 1
else
        s.append("0")