For affluence of presentation and understanding, decimal basis with 7 chiffre attention will be acclimated in the examples, as in the IEEE 754 decimal32 format. The axiological attempt are the aforementioned in any basis or precision, except that normalization is alternative (it does not affect the afterwards amount of the result). Here, s denotes the significand and e denotes the exponent.
editAddition and subtraction
A simple adjustment to add floating-point numbers is to aboriginal represent them with the aforementioned exponent. In the archetype below, the additional amount is confused appropriate by three digits, and we again advance with the accepted accession method:
123456.7 = 1.234567 × 10^5
101.7654 = 1.017654 × 10^2 = 0.001017654 × 10^5
Hence:
123456.7 + 101.7654 = (1.234567 × 10^5) + (1.017654 × 10^2)
= (1.234567 × 10^5) + (0.001017654 × 10^5)
= (1.234567 + 0.001017654) × 10^5
= 1.235584654 × 10^5
In detail:
e=5; s=1.234567 (123456.7)
+ e=2; s=1.017654 (101.7654)
e=5; s=1.234567
+ e=5; s=0.001017654 (after shifting)
--------------------
e=5; s=1.235584654 (true sum: 123558.4654)
This is the accurate result, the exact sum of the operands. It will be angled to seven digits and again normalized if necessary. The final aftereffect is
e=5; s=1.235585 (final sum: 123558.5)
Note that the low 3 digits of the additional operand (654) are about lost. This is round-off error. In acute cases, the sum of two non-zero numbers may be according to one of them:
e=5; s=1.234567
+ e=−3; s=9.876543
e=5; s=1.234567
+ e=5; s=0.00000009876543 (after shifting)
----------------------
e=5; s=1.23456709876543 (true sum)
e=5; s=1.234567 (after rounding/normalization)
Note that in the aloft conceptual examples it would arise that a ample amount of added digits would charge to be provided by the adder to ensure actual rounding: in actuality for bifold accession or addition application accurate accomplishing techniques alone two added bouncer $.25 and one added adhesive bit charge to be agitated above the attention of the operands.16
Another botheration of accident of acceptation occurs if two abutting numbers are subtracted. In the afterward archetype e = 5; s = 1.234571 and e = 5; s = 1.234567 are representations of the rationals 123457.1467 and 123456.659.
e=5; s=1.234571
− e=5; s=1.234567
----------------
e=5; s=0.000004
e=−1; s=4.000000 (after rounding/normalization)
The best representation of this aberration is e = −1; s = 4.877000, which differs added than 20% from e = −1; s = 4.000000. In acute cases, all cogent digits of attention can be absent (although bit-by-bit underflow ensures that the aftereffect will not be aught unless the two operands were equal). This abandoning illustrates the crisis in bold that all of the digits of a computed aftereffect are meaningful. Dealing with the after-effects of these errors is a affair in afterwards analysis; see aswell Accuracy problems.
editMultiplication and division
To multiply, the significands are assorted while the exponents are added, and the aftereffect is angled and normalized.
e=3; s=4.734612
× e=5; s=5.417242
-----------------------
e=8; s=25.648538980104 (true product)
e=8; s=25.64854 (after rounding)
e=9; s=2.564854 (after normalization)
Similarly, analysis is able by adding the divisor's backer from the dividend's exponent, and adding the dividend's significand by the divisor's significand.
There are no abandoning or assimilation problems with multiplication or division, admitting baby errors may accrue as operations are performed in succession.17 In practice, the way these operations are agitated out in agenda argumentation can be absolutely circuitous (see Booth's multiplication algorithm and agenda division).18 For a fast, simple method, see the Horner method.
No comments:
Post a Comment