division by 7 efficiently ???

Bart Ogryczak B.Ogryczak at gmail.com
Fri Feb 2 11:21:08 EST 2007


On Feb 1, 2:00 pm, "Nicko" <use... at nicko.org> wrote:

> precision and the answer that they were looking for was:
>     a = (b * 04444444445L) >> 32
> Note that the constant there is in octal.

04444444445L? Shouldn´t it be  04444444444?
Or more generally,
const = (1<<bitPrecision)/7
a = (b * const)>>bitPrecision





More information about the Python-list mailing list