python 二进制小数
python"># -*- coding:utf-8 -*- class BinDecimal: def printBin(self, num): aa = num*2 rest = [] rest.append(str(int(aa))) while aa != 1: aa = (aa - int(aa))*2 rest.append(str(int(aa))) res = '0.' + "".join(rest) if len(res)>= 32: return "Error" return res aa = BinDecimal() print aa.printBin(0.46502)