In my experiments, failures were happening about 2--3% of the time,
which is way more than one is really willing to tolerate.
* i.e., if %$J \le N - (k + \log_2 N)$%.
*
* Experimentation shows that taking %$k + \log_2 N = 12$% works well for
* i.e., if %$J \le N - (k + \log_2 N)$%.
*
* Experimentation shows that taking %$k + \log_2 N = 12$% works well for
- * %$N = 1024$%, so %$k = 2$%.
+ * %$N = 1024$%, so %$k = 2$%. Add a few extra bits for luck.
*/
for (i = 1; i && nbits >> i; i <<= 1); assert(i);
*/
for (i = 1; i && nbits >> i; i <<= 1); assert(i);
- for (slop = 2, nb = nbits; nb > 1; i >>= 1) {
+ for (slop = 6, nb = nbits; nb > 1; i >>= 1) {
u = nb >> i;
if (u) { slop += i; nb = u; }
}
u = nb >> i;
if (u) { slop += i; nb = u; }
}