简体   繁体   English

浮点数转十进制数

[英]Floating point number to decimal number

I have the following floating point number: 1|011|1001.我有以下浮点数:1|011|1001。 The possible answers in the multiple choice are:多项选择中可能的答案是:
a)-729 a)-729
b)729 b)729
c)72 c)72
d)-72. d)-72。
The answer is d) -72.答案是 d) -72。 But how is it possible?但怎么可能呢? I have no clue how they calculated this.我不知道他们是如何计算的。 I think my school uses another method than what is known in the internet, because when I try it like in all those tutorials i have seen, it doesn't work.我认为我的学校使用了另一种方法,而不是互联网上已知的方法,因为当我像在我看过的所有教程中一样尝试时,它不起作用。 I even tried it backwards like -72 to floating point but the exponent already would be different.我什至尝试向后像 -72 到浮点数,但指数已经不同了。 Can someone explain ist for me?有人可以为我解释一下吗?

In “1|011|1001”, 1 is the sign field, 011 is the exponent field, and 1001 is the significand field.在“1|011|1001”中,1为符号域,011为指数域,1001为有效位域。

The sign bit is 0 for +, 1 for −, so this is −. + 的符号位是 0,- 的符号位是 1,所以这是 -。

011 2 is 3, apparently meaning scaling by 2 3 011 2是 3,显然意味着按 2 3缩放

1001 2 is 9, meaning a significand of 9. 1001 2是 9,意思是 9 的有效数。

So the number is − 2 3 • 9 = −72.所以这个数字是 − 2 3 • 9 = −72。

However, this is not at all a standard format.但是,这根本不是标准格式。 Usually the exponent is biased (offset) by some value.通常指数会被某个值偏置(偏移)。 This is commonly 2 n −1 −1 for an n -bit field, so the bias would be 3 for a 3-bit field, and 001 would represent an exponent of −2, 010 would represent −1, 011 would represent 0, and so on.对于n位字段,这通常是 2 n -1 -1,因此对于 3 位字段,偏差将为 3,001 表示 -2 的指数,010 表示 -1,011 表示 0,等等。

Additionally, the significand field is usually scaled, so that 1001 would represent .1001 2 (9/16) rather than 1001 2 (9).此外,有效位字段通常被缩放,因此 1001 将代表 0.1001 2 (9/16) 而不是 1001 2 (9)。 Also, the significand is usually formed with a leading bit that is 0 or 1 depending on the value of the exponent field.此外,根据指数字段的值,有效数通常由 0 或 1 的前导位构成。

So this format is very different from common formats.所以这种格式与常见的格式有很大的不同。 No test or exercise should expect a student to know it without having documented it previously.任何测试或练习都不应该期望学生在没有事先记录的情况下知道它。

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

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