【问题标题】:Decimal fraction conversion to binary - how to convert 0.1?小数转换为二进制 - 如何转换 0.1?
【发布时间】:2014-01-23 20:28:34
【问题描述】:

我很好奇将十进制小数 0.1 转换为二进制。

如果我有其他小数(例如 0.75),我知道这样做的方法

1) 0.75 * 2 = 1.5 >= 1 - 然后变成 1

2) 0.5 * 2 = 1 >= 1 - 然后变成 1

二进制结果:0,11

但是如果小数部分是 0.1 - 如何应用这个方法?

1) 0.1 * 2 = 0

它变成0,没有别的了

【问题讨论】:

标签: binary


【解决方案1】:
0.1 * 2 = 0.2 --> 0 with remainder 0.2
0.2 * 2 = 0.4 --> 0 with remainder 0.4
0.4 * 2 = 0.8 --> 0 with remainder 0.8
0.8 * 2 = 1.6 --> 1 with remainder 0.6
0.6 * 2 = 1.2 --> 1 with remainder 0.2
0.2 * 2 = 0.4 --> 0 with remainder 0.4
0.4 * 2 = 0.8 --> 0 with remainder 0.8
0.8 * 2 = 1.6 --> 1 with remainder 0.6
0.6 * 2 = 1.2 --> 1 with remainder 0.2

等等。

现在我们取结果,并在它们前面加上一个小数点:

0.0001100110011.......

如此循环往复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 1970-01-01
    • 2011-09-14
    • 2013-11-05
    相关资源
    最近更新 更多