richard-uk1/integer-sqrt-rs

Panic computing sqrt of i32::max_value() and i128::max_value()

Closed this issue · 3 comments

The following minimal example seems to trigger an 'attempt to multiply with overflow' exception on both lines:

println!("{}", i32::max_value().integer_sqrt());
println!("{}", i128::max_value().integer_sqrt());

It doesn't seem to happen with i8, i16, or i64.

Here's an example program with the panic lines commented out: https://gist.github.com/spearman/c40730df9cf58be35a561c2af816cb6f

Great catch!

I've pushed another version (0.1.3) with this bug fixed, and added more thorough testing.

I'll leave open for now in case you're still having problems.

Looks good to me, thanks!