什么是小数点&QUOT后面的数字含义

什么是小数点&QUOT后面的数字含义

本文介绍了在二进制表示,什么是小数点&QUOT后面的数字含义;"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从一个十进制数转换为IEEE 754浮点数重新presentation这个例子

I have this example on how to convert from a base 10 number to IEEE 754 float representation

Number: 45.25 (base 10) = 101101.01 (base 2) Sign: 0
Normalized form N = 1.0110101 * 2^5
Exponent esp = 5  E = 5 + 127 = 132 (base 10) = 10000100 (base 2)
IEEE 754: 0 10000100 01101010000000000000000

这对我来说很有意义,除了一个通道:

This makes sense to me except one passage:

45.25 (base 10) = 101101.01 (base 2)

45是二进制101101那没关系..但他们是怎么获得0.25 .01?

45 is 101101 in binary and that's okay.. but how did they obtain the 0.25 as .01 ?

推荐答案

可以部分小数点后通过由新碱反复乘以转换为另一种碱(在这种情况下,新碱是2),这样的:

You can convert the part after the decimal point to another base by repeatedly multiplying by the new base (in this case the new base is 2), like this:

0.25 * 2 = 0.5

- >第一个二进制数字是0(取整数部分,即小数点前面的部分)

-> The first binary digit is 0 (take the integral part, i.e. the part before the decimal point).

继续小数点后部分乘以:

Continue multiplying with the part after the decimal point:

0.5 * 2 = 1.0

- >第二个二进制位为1(再次,采取不可分割的一部分)

-> The second binary digit is 1 (again, take the integral part).

这也是我们停止,因为小数点之后的部分,现在是零,所以没有什么更多的繁殖。

This is also where we stop because the part after the decimal point is now zero, so there is nothing more to multiply.

因此​​小数部分的最终二进制重新presentation为:0.01

Therefore the final binary representation of the fractional part is: 0.01.

编辑:

也可能是值得注意的是,这是相当频繁的二进制重新presentation是无限与有限的小数部分在基地启动10例甚至当:转换0.2 为二进制:

Might also be worth noting that it's quite often that the binary representation is infinite even when starting with a finite fractional part in base 10. Example: converting 0.2 to binary:

0.2 * 2 = 0.4   ->   0
0.4 * 2 = 0.8   ->   0
0.8 * 2 = 1.6   ->   1
0.6 * 2 = 1.2   ->   1
0.2 * 2 = ...

因此​​,我们结束了。0.001100110011 ...

使用这个方法,你看很容易,如果二进制重新presentation最终被无限的。

Using this method you see quite easily if the binary representation ends up being infinite.

这篇关于在二进制表示,什么是小数点&QUOT后面的数字含义;"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:22