@@ -451,7 +451,7 @@ pub fn from_str_radix_float<T: Float>(src: &str, radix: uint) -> Option<T> {
451451 } ;
452452
453453 // The significand to accumulate
454- let mut sig = if is_positive { _0 } else { -_1 } ;
454+ let mut sig = if is_positive { _0 } else { -_0 } ;
455455 // Necessary to detect overflow
456456 let mut prev_sig = sig;
457457 let mut cs = src. chars ( ) . enumerate ( ) ;
@@ -647,6 +647,22 @@ mod test {
647647 let fe : Option < f32 > = from_str_radix_float ( "1e40" , 10 ) ;
648648 assert_eq ! ( fe, Some ( Float :: infinity( ) ) )
649649 }
650+
651+ #[ test]
652+ fn test_from_str_radix_float ( ) {
653+ let x1 : Option < f64 > = from_str_radix_float ( "-123.456" , 10 ) ;
654+ assert_eq ! ( x1, Some ( -123.456 ) ) ;
655+ let x2 : Option < f32 > = from_str_radix_float ( "123.456" , 10 ) ;
656+ assert_eq ! ( x2, Some ( 123.456 ) ) ;
657+ let x3 : Option < f32 > = from_str_radix_float ( "-0.0" , 10 ) ;
658+ assert_eq ! ( x3, Some ( -0.0 ) ) ;
659+ let x4 : Option < f32 > = from_str_radix_float ( "0.0" , 10 ) ;
660+ assert_eq ! ( x4, Some ( 0.0 ) ) ;
661+ let x4 : Option < f32 > = from_str_radix_float ( "1.0" , 10 ) ;
662+ assert_eq ! ( x4, Some ( 1.0 ) ) ;
663+ let x5 : Option < f32 > = from_str_radix_float ( "-1.0" , 10 ) ;
664+ assert_eq ! ( x5, Some ( -1.0 ) ) ;
665+ }
650666}
651667
652668#[ cfg( test) ]
0 commit comments