From 8ac0d0a59ee47d9f8027955ca13f545f89bcc687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Tue, 8 Oct 2013 20:57:17 +0200 Subject: [PATCH] Fix float to float ToPrimitive implementation. The mimimum (negative) value of a float is -Bounded::max_value(), not Bounded::min_value(). --- src/libstd/num/num.rs | 3 +-- 1 file changed, 1 insertion(+), 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