about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2013-10-08 20:57:17 +0200
committerSébastien Crozet <developer@crozet.re>2013-10-08 21:49:35 +0200
commit8ac0d0a59ee47d9f8027955ca13f545f89bcc687 (patch)
tree9a3af805698c45ed86a57d047be90018094bf0ab
parente42e32291ea779a30818521e8aea9693899b8188 (diff)
downloadrust-8ac0d0a59ee47d9f8027955ca13f545f89bcc687.tar.gz
rust-8ac0d0a59ee47d9f8027955ca13f545f89bcc687.zip
Fix float to float ToPrimitive implementation.
The mimimum (negative) value of a float is -Bounded::max_value(), not Bounded::min_value().
-rw-r--r--src/libstd/num/num.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs
index 379e874f862..aacf807a875 100644
--- a/src/libstd/num/num.rs
+++ b/src/libstd/num/num.rs
@@ -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