Content deleted Content added
→Pseudocode: I somewhat fixed the formatting of the pseudocode. It seems that Mathml is incompatible with all Wikipedia code formatting except "code" tags, but "code" tags aren't great for blocks (rather than inline). This seems the least of all evils. Tag: Reverted |
|||
Line 276:
The following computes the quotient of {{var|N}} and {{var|D}} with a precision of {{var|P}} binary places:
<code>Express D as M × 2<sup>e</sup> where 1 ≤ M < 2 (standard floating point representation)
N' := N / 2<sup>e+1</sup>▼
X := 48/17 − 32/17 × D' ''// precompute constants with same precision as D''▼
▲N' := N / 2<sup>e+1</sup>
{{nowrap|'''repeat''' <math>\left \lceil \log_2 \frac{P + 1}{\log_2 17} \right \rceil \,</math> '''times'''}} ''// can be precomputed based on fixed P''▼
▲X := 48/17 − 32/17 × D' ''// precompute constants with same precision as D''
▲{{nowrap|'''repeat''' <math>\left \lceil \log_2 \frac{P + 1}{\log_2 17} \right \rceil \,</math> '''times'''}} ''// can be precomputed based on fixed P''
X := X + X × (1 - D' × X)
'''end'''
'''return''' N' × X</code>
For example, for a double-precision floating-point division, this method uses 10 multiplies, 9 adds, and 2 shifts.
|