二进制小数,,# -*- coding
二进制小数,,# -*- coding
# -*- 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 resaa = BinDecimal()print aa.printBin(0.46502)
相关内容
- python通过Tkinter显示网络图片,,''' tk_image
- nagios插件--监控inodes,nagios插件inodes,#!/bin/env p
- python(PIL)图像处理(等比例压缩、裁剪压缩) 缩略(水印
- Python动态生成中文验证码,,Python动态生成中文
- lmdb 键值数据库读写测试,lmdb键值数据库读写,import l
- Mysql connector封装,mysqlconnector封装,#!/usr/bin/e
- Python数据库操作,python数据库,文件型数据库sqllit
- python计算两个日期相差的天数,python天数,#两个日期相
- python通过xmlrpc进行远程调用的范例演示,pythonxmlrpc,服务
- 基python实现多线程网页爬虫,python多线程,#!/usr/bin/e
评论关闭