note
salva
My method, first builds an approximation of the solution of <c>a/b</c> as...
<c>
s1 = ((a / 2) / b) * 2;
</c>
<c>a / 2</c> is done using the bug-free shift-right operator (<c>>></c>) and results always in a number with bit 64 unset, so we can divide it by <c>b</c> without incurring in the convert-to-NV bug. Again multiplying by 2 is done with the shift-left operator (<c><<</c>).
<p>Then, we use the approximation to build the exact solution as:
<c>
s = s1 + (a - s1 * b) / b
</c>
<p>Well, actually, in order to do everything using bug-free operations, the code uses the following equivalence:
<c>
s2 = (a / 2) / b
s1 = s2 * 2
s = s1 + (a - s1 * b) / b
s = s2 * 2 + (a - (s2 * b) * 2) / b
</c>
where <c>$d</c> is <c>s2</c>, and <c>$e</c> is <c>(a - (s2 * b) * 2)</c>.
1116920
1116955