简体   繁体   English

binary32 float(IEEE)中的前导位

[英]leading bit in binary32 float(IEEE)

the background for question - specifications of binary32 float 问题的背景 - binary32 float的规范

My question is about assumption, that first (leading) bit is always 1, so we do not need to store it. 我的问题是关于假设,第一个(前导)位总是1,所以我们不需要存储它。 That's true, but it has another role in number.. we know, where it starts. 这是真的,但它在数量上有另一个作用..我们知道,从哪里开始。 So after extracting that first non-zero bit, we don't know where number starts, unless there's another non-zero bit right afterwards. 因此,在提取出第一个非零位后,我们不知道数字的开始位置,除非之后有另一个非零位。

In that wiki article, they use number (1.100011)binary. 在那篇wiki文章中,他们使用数字(1.100011)二进制文件。 So fraction is 100011 and we can build up that number back without problem. 因此分数是100011,我们可以毫无问题地建立这个数字。 However, what about (1.000011)binary? 但是,(1.000011)二进制呢? we extract 1 and we're left with 000011, and as we can't store leading zeroes inside zero-initialized bitfield, we get 11. But what happens, when we want to build it back? 我们提取1并且我们留下了000011,并且因为我们不能在零初始化的位域中存储前导零,所以我们得到11.但是当我们想要构建它时会发生什么呢? we get 1.11 and that's wrong. 我们得到1.11,那是错的。

So how we can freely extract that leading bit in arbitrary number? 那么我们如何能够自由地提取任意数量的前导位?

However, what about (1.000011)binary? 但是,(1.000011)二进制呢? we extract 1 and we're left with 000011, and as we can't store leading zeroes inside zero-initialized bitfield, we get 11. 我们提取1并且我们留下了000011,并且因为我们不能在零初始化位域内存储前导零,所以得到11。

In fact you do store leading zeros. 事实上,你确实存储了前导零。 What is stored is 000011 and when the 1 is added back in you are back where you started. 存储的内容是000011,当重新添加1时,您回到了开始的位置。 Storing the leading zeros (after the leading 1 has been removed) is what makes it work. 存储前导零(在删除前导1之后)是使它工作的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM