Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从0.0到X.7生成位号-python_Python_Byte_Bit - Fatal编程技术网

从0.0到X.7生成位号-python

从0.0到X.7生成位号-python,python,byte,bit,Python,Byte,Bit,我想用python生成位地址,从0.0开始,到X.7结束 如何构建一个当位地址超过X.7时增加字节数的函数 例如: Input = 0.7 + 0.1 (0.8) >> Output = 1.0 Input = 1.7 + 0.1 (1.8) >> Output = 2.0 您的内部表示可以是一些非负整数位数: >>> 7 + 1 8 >>> 15 + 1 16 然后,您可以在需要字符串表示时将其转换为虚线格式: def格

我想用python生成位地址,从0.0开始,到X.7结束

如何构建一个当位地址超过X.7时增加字节数的函数

例如:

Input = 0.7 + 0.1 (0.8)  >> Output = 1.0

Input = 1.7 + 0.1 (1.8)  >>  Output = 2.0

您的内部表示可以是一些非负整数位数:

>>> 7 + 1
8

>>> 15 + 1
16
然后,您可以在需要字符串表示时将其转换为虚线格式:

def格式位地址(位):
返回f“{bit//8}.{bit%8}”
>格式位地址(7)
'0.7'
>>>格式位地址(1)
'0.1'
>>>格式位地址(7+1)
'1.0'