division by 7 efficiently ???
Nicko
usenet at nicko.org
Fri Feb 2 12:36:17 EST 2007
On Feb 1, 8:25 pm, "Krypto" <krypto.wiz... at gmail.com> wrote:
> The correct answer as told to me by a person is
>
> (N>>3) + ((N-7*(N>>3))>>3)
>
> The above term always gives division by 7
No it doesn't. The above term tends towards N * (9/64), with some
significant rounding errors. 9/64 is a fairly poor (6 bit)
approximation of 1/7 but the principle is the same as the solution I
proposed above.
Nicko
More information about the Python-list
mailing list