Open cuviper opened 6 years ago
self.denom
is compared toZero::zero
instead of callingis_zero()
.
This is fixed.
This might mean that Rust needs some general guideline on how to treat integer overflow.
I think we should adopt the same behavior as for the primitive integer types: Panic in debug mode, silently fail in release mode. This would mean that this issue and #11 can be just closed, because all remaining cases already panic in debug mode.
We could add debug_assert
s, but I don't think it adds much.
From @rust-highfive on September 28, 2014 22:43
Issue by tbu- Saturday Aug 09, 2014 at 13:25 GMT
For earlier discussion, see https://github.com/rust-lang/rust/issues/16386
This issue was labelled with: in the Rust repository
Ratio::reduce
, where the unary minus operator on a negative number is assumed to yield a positive number.self.denom
is compared toZero::zero
instead of callingis_zero()
.Ratio::recip
might return a fractions with a denominator of0
.There are also some issues regarding overflows, it seems the module just hopes that they won't happen at all – except for wrong results, this could also raise a
fail!()
ure, when e.g.1/sqrt(max_int)
is multiplied with itself, yielding1/0
.This might mean that Rust needs some general guideline on how to treat integer overflow.
Copied from original issue: rust-num/num#11