Skip to content

Commit 8ac0d0a

Browse files
committed
Fix float to float ToPrimitive implementation.
The mimimum (negative) value of a float is -Bounded::max_value(), not Bounded::min_value().
1 parent e42e322 commit 8ac0d0a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/libstd/num/num.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,8 @@ macro_rules! impl_to_primitive_float_to_float(
567567
Some(*self as $DstT)
568568
} else {
569569
let n = *self as f64;
570-
let min_value: $SrcT = Bounded::min_value();
571570
let max_value: $SrcT = Bounded::max_value();
572-
if min_value as f64 <= n && n <= max_value as f64 {
571+
if -max_value as f64 <= n && n <= max_value as f64 {
573572
Some(*self as $DstT)
574573
} else {
575574
None

0 commit comments

Comments
 (0)