You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue was labelled with: in the Rust repository
Possible-machine integers are treated as mathematical integers: Ratio::reduce, where the unary minus operator on a negative number is assumed to yield a positive number.
self.denom is compared to Zero::zero instead of calling is_zero().
Ratio::recip might return a fractions with a denominator of 0.
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, yielding 1/0.
This might mean that Rust needs some general guideline on how to treat integer overflow.
self.denom is compared to Zero::zero instead of calling is_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_asserts, 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 rust-lang/rust#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
The text was updated successfully, but these errors were encountered: