浮点除法和乘法。结果尾数是如何得到的?
Floating point division and multiplication. How is the resulting mantissa obtained?
我知道如何用二进制加减浮点数。对于乘法和除法,我必须 multiply/divide 尾数和 add/subtract 指数。
但这是我不明白的事情。尾数是分数,我只学过整数乘除法。什么规则适用于尾数算术?我见过一些例子,其中乘法尾数被视为整数,但是对于除法,余数会怎样?
有人可以提供一个尾数除法的例子吗?
(首选术语是“有效数”。“尾数”是纸质对数表时代的遗留术语。)
添加三位有效数字的示例:
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.
请注意,在这些示例中,被加减的数字的有效数字已经对齐。当添加的数字的指数相等时,就会发生这种情况。如果不是,则必须移动其中一个数以使其指数等于另一个数,然后可以添加或减去尾数。
除法与您在学校学到的长除法相同。您将除法运算为有效数字所需的位数,然后使用该点的余数来决定是向上舍入还是向下舍入。
我知道如何用二进制加减浮点数。对于乘法和除法,我必须 multiply/divide 尾数和 add/subtract 指数。
但这是我不明白的事情。尾数是分数,我只学过整数乘除法。什么规则适用于尾数算术?我见过一些例子,其中乘法尾数被视为整数,但是对于除法,余数会怎样? 有人可以提供一个尾数除法的例子吗?
(首选术语是“有效数”。“尾数”是纸质对数表时代的遗留术语。)
添加三位有效数字的示例:
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.
请注意,在这些示例中,被加减的数字的有效数字已经对齐。当添加的数字的指数相等时,就会发生这种情况。如果不是,则必须移动其中一个数以使其指数等于另一个数,然后可以添加或减去尾数。
除法与您在学校学到的长除法相同。您将除法运算为有效数字所需的位数,然后使用该点的余数来决定是向上舍入还是向下舍入。