num-traits/src
bors[bot] e796afc83a Merge #73
73: Avoid `as` casts in default FromPrimitive methods r=cuviper a=cuviper

Particularly, the default `from_f64` used `n as i64`, which has
undefined behavior on overflow, kind of defeating the purpose here.
Now we use a checked `to_i64()` for this, and even try `to_u64()` as a
fallback for completeness.

Also make similar changes to default `ToPrimitive`, but at least it
didn't have the same casting problem.

Co-authored-by: Josh Stone <cuviper@gmail.com>
2018-06-20 21:26:19 +00:00
..
ops Clarify in the docs that `mul_add` is not always faster. 2018-05-20 11:58:10 -04:00
bounds.rs Automatically detect support for i128/u128 2018-05-11 15:50:48 -07:00
cast.rs doc: fix a typo, s/the/then/ 2018-06-20 13:39:08 -07:00
float.rs Clarify in the docs that `mul_add` is not always faster. 2018-05-20 11:58:10 -04:00
identities.rs Automatically detect support for i128/u128 2018-05-11 15:50:48 -07:00
int.rs Automatically detect support for i128/u128 2018-05-11 15:50:48 -07:00
lib.rs Automatically detect support for i128/u128 2018-05-11 15:50:48 -07:00
macros.rs allow unused macros 2018-02-27 17:09:43 -08:00
pow.rs Automatically detect support for i128/u128 2018-05-11 15:50:48 -07:00
real.rs Clarify in the docs that `mul_add` is not always faster. 2018-05-20 11:58:10 -04:00
sign.rs Automatically detect support for i128/u128 2018-05-11 15:50:48 -07:00