@@ -341,89 +341,60 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
341341 r
342342}
343343
344- /// Convert a string in base 16 to a float.
345- /// Accepts an optional binary exponent.
346- ///
347- /// This function accepts strings such as
348- ///
349- /// * 'a4.fe'
350- /// * '+a4.fe', equivalent to 'a4.fe'
351- /// * '-a4.fe'
352- /// * '2b.aP128', or equivalently, '2b.ap128'
353- /// * '2b.aP-128'
354- /// * '.' (understood as 0)
355- /// * 'c.'
356- /// * '.c', or, equivalently, '0.c'
357- /// * '+inf', 'inf', '-inf', 'NaN'
358- ///
359- /// Leading and trailing whitespace represent an error.
360- ///
361- /// # Arguments
362- ///
363- /// * num - A string
364- ///
365- /// # Return value
366- ///
367- /// `None` if the string did not represent a valid number. Otherwise,
368- /// `Some(n)` where `n` is the floating-point number represented by `[num]`.
369344#[ inline]
370- pub fn from_str_hex ( num : & str ) -> Option < f64 > {
371- strconv:: from_str_radix_float ( num, 16 u)
345+ #[ deprecated="Use `FromStrRadix::from_str_radix(src, 16)`" ]
346+ pub fn from_str_hex ( src : & str ) -> Option < f64 > {
347+ strconv:: from_str_radix_float ( src, 16 )
372348}
373349
374350impl FromStr for f64 {
375351 /// Convert a string in base 10 to a float.
376352 /// Accepts an optional decimal exponent.
377353 ///
378- /// This function accepts strings such as
354+ /// This function accepts strings such as:
379355 ///
380356 /// * '3.14'
381- /// * '+3.14', equivalent to '3.14'
382357 /// * '-3.14'
383358 /// * '2.5E10', or equivalently, '2.5e10'
384359 /// * '2.5E-10'
385360 /// * '.' (understood as 0)
386361 /// * '5.'
387362 /// * '.5', or, equivalently, '0.5'
388- /// * '+inf', ' inf', '-inf', 'NaN'
363+ /// * inf', '-inf', 'NaN'
389364 ///
390365 /// Leading and trailing whitespace represent an error.
391366 ///
392367 /// # Arguments
393368 ///
394- /// * num - A string
369+ /// * src - A string
395370 ///
396371 /// # Return value
397372 ///
398373 /// `none` if the string did not represent a valid number. Otherwise,
399- /// `Some(n)` where `n` is the floating-point number represented by `num `.
374+ /// `Some(n)` where `n` is the floating-point number represented by `src `.
400375 #[ inline]
401- fn from_str ( val : & str ) -> Option < f64 > {
402- strconv:: from_str_radix_float ( val , 10 u)
376+ fn from_str ( src : & str ) -> Option < f64 > {
377+ strconv:: from_str_radix_float ( src , 10 u)
403378 }
404379}
405380
406381impl num:: FromStrRadix for f64 {
407382 /// Convert a string in a given base to a float.
408383 ///
409- /// Due to possible conflicts, this function does **not** accept
410- /// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor**
411- /// does it recognize exponents of any kind.
412- ///
413384 /// Leading and trailing whitespace represent an error.
414385 ///
415386 /// # Arguments
416387 ///
417- /// * num - A string
388+ /// * src - A string
418389 /// * radix - The base to use. Must lie in the range [2 .. 36]
419390 ///
420391 /// # Return value
421392 ///
422393 /// `None` if the string did not represent a valid number. Otherwise,
423- /// `Some(n)` where `n` is the floating-point number represented by `num `.
394+ /// `Some(n)` where `n` is the floating-point number represented by `src `.
424395 #[ inline]
425- fn from_str_radix ( val : & str , radix : uint ) -> Option < f64 > {
426- strconv:: from_str_radix_float ( val , radix)
396+ fn from_str_radix ( src : & str , radix : uint ) -> Option < f64 > {
397+ strconv:: from_str_radix_float ( src , radix)
427398 }
428399}
429400
@@ -709,8 +680,8 @@ mod tests {
709680 fn test_ldexp ( ) {
710681 // We have to use from_str until base-2 exponents
711682 // are supported in floating-point literals
712- let f1: f64 = from_str_hex ( "1p-123" ) . unwrap ( ) ;
713- let f2: f64 = from_str_hex ( "1p-111" ) . unwrap ( ) ;
683+ let f1: f64 = FromStrRadix :: from_str_radix ( "1p-123" , 16 ) . unwrap ( ) ;
684+ let f2: f64 = FromStrRadix :: from_str_radix ( "1p-111" , 16 ) . unwrap ( ) ;
714685 assert_eq ! ( FloatMath :: ldexp( 1f64 , -123 ) , f1) ;
715686 assert_eq ! ( FloatMath :: ldexp( 1f64 , -111 ) , f2) ;
716687
@@ -729,8 +700,8 @@ mod tests {
729700 fn test_frexp ( ) {
730701 // We have to use from_str until base-2 exponents
731702 // are supported in floating-point literals
732- let f1: f64 = from_str_hex ( "1p-123" ) . unwrap ( ) ;
733- let f2: f64 = from_str_hex ( "1p-111" ) . unwrap ( ) ;
703+ let f1: f64 = FromStrRadix :: from_str_radix ( "1p-123" , 16 ) . unwrap ( ) ;
704+ let f2: f64 = FromStrRadix :: from_str_radix ( "1p-111" , 16 ) . unwrap ( ) ;
734705 let ( x1, exp1) = f1. frexp ( ) ;
735706 let ( x2, exp2) = f2. frexp ( ) ;
736707 assert_eq ! ( ( x1, exp1) , ( 0.5f64 , -122 ) ) ;
0 commit comments