Content deleted Content added
Quuxplusone (talk | contribs) m turn code's 2 ifs into a single if-else |
→Restoring division: A readable version of the restoring division algorithm |
||
Line 18:
===Restoring division===
Restoring division operates on [[fixed-point]] fractional numbers and depends on the following assumptions:
*
*
The quotient digits ''q'' are formed from the digit set {0,1}.
Line 25:
The basic algorithm for binary (radix 2) restoring division is:
P
'''for''' i = n-1..0 '''do''' ''* for example 31..0 for 32 bits''
P := 2P - D ''* trial subtraction from shifted value''
'''else'''
q
P := P + D ''* new partial remainder is (restored) shifted value''
'''end
▲ '''end while'''
'''where''' ''N=Numerator, D=Denominator, n=#bits, P=Partial remainder, q(i)=bit #i of quotient''
Non-performing restoring division is similar to restoring division except that the value of <code>2*P[i]</code> is saved, so ''D'' does not need to be added back in for the case of <code>TP[i] ≤ 0</code>.
|