【问题标题】:Floating point division and multiplication. How is the resulting mantissa obtained?浮点除法和乘法。得到的尾数是如何得到的?
【发布时间】:2018-07-19 17:45:57
【问题描述】:

我知道如何在二进制中添加或减去浮点数。对于乘法和除法,我必须乘/除尾数并加/减指数。

但这是我不明白的事情。尾数是分数,我只学会了如何乘除整数。什么规则适用于尾数算术?我见过一些例子,其中乘法尾数被视为整数,但是,对于除法,余数会发生什么? 有人可以提供一个尾数除法的例子吗?

【问题讨论】:

    标签: math binary floating-point division multiplication


    【解决方案1】:

    (首选术语是“有效位”。“尾数”是纸质对数表时代的传统术语。)

    添加三位有效数字的示例:

     1.01
    +1.11
    _____
    11.00
    Result >= 10.00, so shift to 1.100, round to 1.10, and add one to exponent.
    
     1.00
    +1.11
    _____
    10.11
    Result >= 10.00, so shift to 1.011, round to 1.10, and add one to exponent.
    

    减去三位有效数的示例:

     1.01
    -1.10
    Note the latter value is larger in magnitude, so swap
    them and remember to invert the sign of the result later.
     1.10
    -1.01
    _____
     0.01
    Result < 1.00, so shift to 1.00 and subtract two from exponent.
    

    三位有效数相乘的示例:

       1.01
      *1.10
    _______
      .0000
      .101
    +1.01
    _______
     1.1110
    Result is in range, so do not shift. Rounding
    requires rounding up, producing 10.0, which is
    >= 10.0, so shift to 1.00 and add one to exponent.
    

    请注意,在这些示例中,被加减的数字的有效位已经对齐。当被添加数字的指数相等时,就会发生这种情况。如果不是,则必须移动其中一个数字以使其指数等于另一个,然后可以添加或减去有效数字。

    除法是用你在学校学过的长除法完成的。您可以根据需要对有效位数执行除法,然后使用该点的余数来决定是向上还是向下舍入。

    【讨论】:

      猜你喜欢
      • 2023-01-20
      • 2018-12-23
      • 1970-01-01
      • 2023-03-25
      • 2011-05-06
      • 2022-08-22
      • 2016-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多