小编San*_*esí的帖子

为什么代表1.0和2.0的位串如此不同?

我最近开始使用Julia,我发现了bits函数,它返回其数字参数的位串表示.例如:

julia> bits(1.0)
"0011111111110000000000000000000000000000000000000000000000000000"
Run Code Online (Sandbox Code Playgroud)

但是,在使用此功能时,我惊讶地发现bits返回非常不同的位串1.02.0:

julia> bits(1.0)
"0011111111110000000000000000000000000000000000000000000000000000"

julia> bits(2.0)
"0100000000000000000000000000000000000000000000000000000000000000"
Run Code Online (Sandbox Code Playgroud)

我原以为这两个值是相似的......

那些位是什么意思?我含糊地回忆起有关编码指数的比特(来自我的数值分析类),但我真的不记得了,我没有设法在网上找到一个好的描述......

floating-point ieee-754 julia

2
推荐指数
1
解决办法
169
查看次数

标签 统计

floating-point ×1

ieee-754 ×1

julia ×1