Fix issue extending f32::MIN/MAX to f64 and improve testcrate.
I was able to trigger an issue extending f32::MAX or f32::MIN to a f64. Issue was not triggered by `testcrate` mainly because f32::MAX/MIN are not in the list of special values to generate. This PR fix the issue and improve `testcrate` adding MAX/MIN/MIN_POSITIVE in the list of special values.
This commit is contained in:
parent
2801c99793
commit
306764b091
|
@ -41,7 +41,7 @@ fn extend<F: Float, R: Float>(a: F) -> R where
|
||||||
let abs_dst: R::Int = a_abs.cast();
|
let abs_dst: R::Int = a_abs.cast();
|
||||||
let bias_dst: R::Int = exp_bias_delta.cast();
|
let bias_dst: R::Int = exp_bias_delta.cast();
|
||||||
abs_result = abs_dst.wrapping_shl(sign_bits_delta);
|
abs_result = abs_dst.wrapping_shl(sign_bits_delta);
|
||||||
abs_result |= bias_dst.wrapping_shl(dst_sign_bits);
|
abs_result += bias_dst.wrapping_shl(dst_sign_bits);
|
||||||
} else if a_abs >= src_infinity {
|
} else if a_abs >= src_infinity {
|
||||||
// a is NaN or infinity.
|
// a is NaN or infinity.
|
||||||
// Conjure the result by beginning with infinity, then setting the qNaN
|
// Conjure the result by beginning with infinity, then setting the qNaN
|
||||||
|
|
|
@ -703,6 +703,9 @@ macro_rules! gen_float {
|
||||||
// Special values
|
// Special values
|
||||||
*rng.choose(&[-0.0,
|
*rng.choose(&[-0.0,
|
||||||
0.0,
|
0.0,
|
||||||
|
::std::$fty::MIN,
|
||||||
|
::std::$fty::MIN_POSITIVE,
|
||||||
|
::std::$fty::MAX,
|
||||||
::std::$fty::NAN,
|
::std::$fty::NAN,
|
||||||
::std::$fty::INFINITY,
|
::std::$fty::INFINITY,
|
||||||
-::std::$fty::INFINITY])
|
-::std::$fty::INFINITY])
|
||||||
|
@ -754,6 +757,9 @@ macro_rules! gen_large_float {
|
||||||
// Special values
|
// Special values
|
||||||
*rng.choose(&[-0.0,
|
*rng.choose(&[-0.0,
|
||||||
0.0,
|
0.0,
|
||||||
|
::std::$fty::MIN,
|
||||||
|
::std::$fty::MIN_POSITIVE,
|
||||||
|
::std::$fty::MAX,
|
||||||
::std::$fty::NAN,
|
::std::$fty::NAN,
|
||||||
::std::$fty::INFINITY,
|
::std::$fty::INFINITY,
|
||||||
-::std::$fty::INFINITY])
|
-::std::$fty::INFINITY])
|
||||||
|
|
Loading…
Reference in New Issue