On Feb 2, 4:21 pm, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > On Feb 1, 2:00 pm, "Nicko" <[EMAIL PROTECTED]> 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
It's to do with rounding. What you actually need is ceiling((1<<bitPrecision)/7), rather than floor((1<<bitPrecision)/7). Nicko -- http://mail.python.org/mailman/listinfo/python-list