小编Hen*_*ski的帖子

将二进制字符串转换为 IEEE-754 单精度 - Python

我有一个由 NumPy 创建的二进制矩阵。该矩阵有 5 行和 32 列。

array([[1, 1, ..., 1, 1],
   [0, 1, ..., 0, 1],
   [1, 1, ..., 0, 1],
   [0, 0, ..., 1, 0],
   [1, 1, ..., 0, 1]])
Run Code Online (Sandbox Code Playgroud)

我将矩阵行转换为字符串,然后放在整数旁边。

str = ''.join(map(str,array[0])).replace(' ','') 
int(str, base=2)
Run Code Online (Sandbox Code Playgroud)

如何将字符串转换为浮点数(float32 - IEEE-754 single)?

python arrays floating-point numpy python-2.7

3
推荐指数
1
解决办法
2171
查看次数

标签 统计

arrays ×1

floating-point ×1

numpy ×1

python ×1

python-2.7 ×1