about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-11-02 22:58:46 +1100
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-11-04 00:20:37 +1100
commit8bd37e672411bf004a4ad64bb7d2160e455a72b0 (patch)
tree9040cc58cc6aa3d6ba5f4f99c837f46494ddee6c /src/libstd/num
parent01ded5898b1863e195856d2678323315ae224463 (diff)
downloadrust-8bd37e672411bf004a4ad64bb7d2160e455a72b0.tar.gz
rust-8bd37e672411bf004a4ad64bb7d2160e455a72b0.zip
Deprecate {f32, f64}::from_str_hex
This is now covered by `FromStrRadix::from_str_radix`
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/f32.rs44
-rw-r--r--src/libstd/num/f64.rs63
2 files changed, 27 insertions, 80 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index ebb1aee816e..63c3956ef24 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -333,34 +333,10 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String {
     r
 }
 
-/// Convert a string in base 16 to a float.
-/// Accepts an optional binary exponent.
-///
-/// This function accepts strings such as
-///
-/// * 'a4.fe'
-/// * '+a4.fe', equivalent to 'a4.fe'
-/// * '-a4.fe'
-/// * '2b.aP128', or equivalently, '2b.ap128'
-/// * '2b.aP-128'
-/// * '.' (understood as 0)
-/// * 'c.'
-/// * '.c', or, equivalently,  '0.c'
-/// * '+inf', 'inf', '-inf', 'NaN'
-///
-/// Leading and trailing whitespace represent an error.
-///
-/// # Arguments
-///
-/// * num - A string
-///
-/// # Return value
-///
-/// `None` if the string did not represent a valid number.  Otherwise,
-/// `Some(n)` where `n` is the floating-point number represented by `[num]`.
 #[inline]
+#[deprecated="Use `FromStrRadix::from_str_radix(src, 16)`"]
 pub fn from_str_hex(src: &str) -> Option<f32> {
-    strconv::from_str_radix_float(src, 16u)
+    strconv::from_str_radix_float(src, 16)
 }
 
 impl FromStr for f32 {
@@ -383,12 +359,12 @@ impl FromStr for f32 {
     ///
     /// # Arguments
     ///
-    /// * num - A string
+    /// * src - A string
     ///
     /// # Return value
     ///
     /// `None` if the string did not represent a valid number.  Otherwise,
-    /// `Some(n)` where `n` is the floating-point number represented by `num`.
+    /// `Some(n)` where `n` is the floating-point number represented by `src`.
     #[inline]
     fn from_str(src: &str) -> Option<f32> {
         strconv::from_str_radix_float(src, 10u)
@@ -406,13 +382,13 @@ impl num::FromStrRadix for f32 {
     ///
     /// # Arguments
     ///
-    /// * num - A string
+    /// * src - A string
     /// * radix - The base to use. Must lie in the range [2 .. 36]
     ///
     /// # Return value
     ///
     /// `None` if the string did not represent a valid number. Otherwise,
-    /// `Some(n)` where `n` is the floating-point number represented by `num`.
+    /// `Some(n)` where `n` is the floating-point number represented by `src`.
     #[inline]
     fn from_str_radix(src: &str, radix: uint) -> Option<f32> {
         strconv::from_str_radix_float(src, radix)
@@ -707,8 +683,8 @@ mod tests {
     fn test_ldexp() {
         // We have to use from_str until base-2 exponents
         // are supported in floating-point literals
-        let f1: f32 = from_str_hex("1p-123").unwrap();
-        let f2: f32 = from_str_hex("1p-111").unwrap();
+        let f1: f32 = FromStrRadix::from_str_radix("1p-123", 16).unwrap();
+        let f2: f32 = FromStrRadix::from_str_radix("1p-111", 16).unwrap();
         assert_eq!(FloatMath::ldexp(1f32, -123), f1);
         assert_eq!(FloatMath::ldexp(1f32, -111), f2);
 
@@ -727,8 +703,8 @@ mod tests {
     fn test_frexp() {
         // We have to use from_str until base-2 exponents
         // are supported in floating-point literals
-        let f1: f32 = from_str_hex("1p-123").unwrap();
-        let f2: f32 = from_str_hex("1p-111").unwrap();
+        let f1: f32 = FromStrRadix::from_str_radix("1p-123", 16).unwrap();
+        let f2: f32 = FromStrRadix::from_str_radix("1p-111", 16).unwrap();
         let (x1, exp1) = f1.frexp();
         let (x2, exp2) = f2.frexp();
         assert_eq!((x1, exp1), (0.5f32, -122));
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index e1a46f5710f..6e8e92eb91d 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -341,89 +341,60 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
     r
 }
 
-/// Convert a string in base 16 to a float.
-/// Accepts an optional binary exponent.
-///
-/// This function accepts strings such as
-///
-/// * 'a4.fe'
-/// * '+a4.fe', equivalent to 'a4.fe'
-/// * '-a4.fe'
-/// * '2b.aP128', or equivalently, '2b.ap128'
-/// * '2b.aP-128'
-/// * '.' (understood as 0)
-/// * 'c.'
-/// * '.c', or, equivalently,  '0.c'
-/// * '+inf', 'inf', '-inf', 'NaN'
-///
-/// Leading and trailing whitespace represent an error.
-///
-/// # Arguments
-///
-/// * num - A string
-///
-/// # Return value
-///
-/// `None` if the string did not represent a valid number.  Otherwise,
-/// `Some(n)` where `n` is the floating-point number represented by `[num]`.
 #[inline]
-pub fn from_str_hex(num: &str) -> Option<f64> {
-    strconv::from_str_radix_float(num, 16u)
+#[deprecated="Use `FromStrRadix::from_str_radix(src, 16)`"]
+pub fn from_str_hex(src: &str) -> Option<f64> {
+    strconv::from_str_radix_float(src, 16)
 }
 
 impl FromStr for f64 {
     /// Convert a string in base 10 to a float.
     /// Accepts an optional decimal exponent.
     ///
-    /// This function accepts strings such as
+    /// This function accepts strings such as:
     ///
     /// * '3.14'
-    /// * '+3.14', equivalent to '3.14'
     /// * '-3.14'
     /// * '2.5E10', or equivalently, '2.5e10'
     /// * '2.5E-10'
     /// * '.' (understood as 0)
     /// * '5.'
     /// * '.5', or, equivalently,  '0.5'
-    /// * '+inf', 'inf', '-inf', 'NaN'
+    /// * inf', '-inf', 'NaN'
     ///
     /// Leading and trailing whitespace represent an error.
     ///
     /// # Arguments
     ///
-    /// * num - A string
+    /// * src - A string
     ///
     /// # Return value
     ///
     /// `none` if the string did not represent a valid number.  Otherwise,
-    /// `Some(n)` where `n` is the floating-point number represented by `num`.
+    /// `Some(n)` where `n` is the floating-point number represented by `src`.
     #[inline]
-    fn from_str(val: &str) -> Option<f64> {
-        strconv::from_str_radix_float(val, 10u)
+    fn from_str(src: &str) -> Option<f64> {
+        strconv::from_str_radix_float(src, 10u)
     }
 }
 
 impl num::FromStrRadix for f64 {
     /// Convert a string in a given base to a float.
     ///
-    /// Due to possible conflicts, this function does **not** accept
-    /// the special values `inf`, `-inf`, `+inf` and `NaN`, **nor**
-    /// does it recognize exponents of any kind.
-    ///
     /// Leading and trailing whitespace represent an error.
     ///
     /// # Arguments
     ///
-    /// * num - A string
+    /// * src - A string
     /// * radix - The base to use. Must lie in the range [2 .. 36]
     ///
     /// # Return value
     ///
     /// `None` if the string did not represent a valid number. Otherwise,
-    /// `Some(n)` where `n` is the floating-point number represented by `num`.
+    /// `Some(n)` where `n` is the floating-point number represented by `src`.
     #[inline]
-    fn from_str_radix(val: &str, radix: uint) -> Option<f64> {
-        strconv::from_str_radix_float(val, radix)
+    fn from_str_radix(src: &str, radix: uint) -> Option<f64> {
+        strconv::from_str_radix_float(src, radix)
     }
 }
 
@@ -709,8 +680,8 @@ mod tests {
     fn test_ldexp() {
         // We have to use from_str until base-2 exponents
         // are supported in floating-point literals
-        let f1: f64 = from_str_hex("1p-123").unwrap();
-        let f2: f64 = from_str_hex("1p-111").unwrap();
+        let f1: f64 = FromStrRadix::from_str_radix("1p-123", 16).unwrap();
+        let f2: f64 = FromStrRadix::from_str_radix("1p-111", 16).unwrap();
         assert_eq!(FloatMath::ldexp(1f64, -123), f1);
         assert_eq!(FloatMath::ldexp(1f64, -111), f2);
 
@@ -729,8 +700,8 @@ mod tests {
     fn test_frexp() {
         // We have to use from_str until base-2 exponents
         // are supported in floating-point literals
-        let f1: f64 = from_str_hex("1p-123").unwrap();
-        let f2: f64 = from_str_hex("1p-111").unwrap();
+        let f1: f64 = FromStrRadix::from_str_radix("1p-123", 16).unwrap();
+        let f2: f64 = FromStrRadix::from_str_radix("1p-111", 16).unwrap();
         let (x1, exp1) = f1.frexp();
         let (x2, exp2) = f2.frexp();
         assert_eq!((x1, exp1), (0.5f64, -122));