Skip to content

Commit

Permalink
Fix float to float ToPrimitive implementation.
Browse files Browse the repository at this point in the history
The mimimum (negative) value of a float is -Bounded::max_value(), not Bounded::min_value().
  • Loading branch information
sebcrozet committed Oct 8, 2013
1 parent e42e322 commit 8ac0d0a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/libstd/num/num.rs
Expand Up @@ -567,9 +567,8 @@ macro_rules! impl_to_primitive_float_to_float(
Some(*self as $DstT)
} else {
let n = *self as f64;
let min_value: $SrcT = Bounded::min_value();
let max_value: $SrcT = Bounded::max_value();
if min_value as f64 <= n && n <= max_value as f64 {
if -max_value as f64 <= n && n <= max_value as f64 {
Some(*self as $DstT)
} else {
None
Expand Down

5 comments on commit 8ac0d0a

@bors
Copy link
Contributor

@bors bors commented on 8ac0d0a Oct 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at sebcrozet@8ac0d0a

@bors
Copy link
Contributor

@bors bors commented on 8ac0d0a Oct 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sebcrozet/rust/master = 8ac0d0a into auto

@bors
Copy link
Contributor

@bors bors commented on 8ac0d0a Oct 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sebcrozet/rust/master = 8ac0d0a merged ok, testing candidate = 8f4b872

@bors
Copy link
Contributor

@bors bors commented on 8ac0d0a Oct 10, 2013

@bors
Copy link
Contributor

@bors bors commented on 8ac0d0a Oct 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 8f4b872

Please sign in to comment.