On Thu, Sep 1, 2016 at 6:36 AM, Theo Buehler <[email protected]> wrote:
> In factor(6), there is the line
>
> 216             stop = usqrt(val) + 1;
>
> where the u_int64_t stop is the upper bound for the sieve of
> Eratosthenes (I cautiously added 1 to be sure to be on the safe side).
> Unfortunately, the right hand side may now overflow for large enough
> val because my brilliant former self chose usqrt() to be of type
> u_int32_t usqrt(u_sqrt64_t); ...

Yeah, it might seem that square-root of a 64bit number should fit in
32bits, but nope, there's a range at the top where the square-root
takes 33bits.

ok guenther@

Reply via email to