diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-08-18 12:23:48 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-08-20 22:05:03 -0400 |
| commit | 0ba8ccdaee358f34589d5e8e0335cf42e057b729 (patch) | |
| tree | c469d95f9b675d7e68d7e2152bc125199994ce38 | |
| parent | 46fc549fa98d473f925b04e53d08f26c2e15bc2a (diff) | |
| download | rust-0ba8ccdaee358f34589d5e8e0335cf42e057b729.tar.gz rust-0ba8ccdaee358f34589d5e8e0335cf42e057b729.zip | |
rm obsolete float to_str_radix free functions
| -rw-r--r-- | src/libstd/num/f32.rs | 41 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 41 | ||||
| -rw-r--r-- | src/libstd/num/float.rs | 45 |
3 files changed, 53 insertions, 74 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 17175de9b92..a493dba467e 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -741,29 +741,6 @@ pub fn to_str_hex(num: f32) -> ~str { } /// -/// Converts a float to a string in a given radix -/// -/// # Arguments -/// -/// * num - The float value -/// * radix - The base to use -/// -/// # Failure -/// -/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to -/// possible misinterpretation of the result at higher bases. If those values -/// are expected, use `to_str_radix_special()` instead. -/// -#[inline] -pub fn to_str_radix(num: f32, rdx: uint) -> ~str { - let (r, special) = strconv::float_to_str_common( - num, rdx, true, strconv::SignNeg, strconv::DigAll); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r -} - -/// /// Converts a float to a string in a given radix, and a flag indicating /// whether it's a special value /// @@ -816,9 +793,25 @@ impl to_str::ToStr for f32 { } impl num::ToStrRadix for f32 { + /// Converts a float to a string in a given radix + /// + /// # Arguments + /// + /// * num - The float value + /// * radix - The base to use + /// + /// # Failure + /// + /// Fails if called on a special value like `inf`, `-inf` or `NaN` due to + /// possible misinterpretation of the result at higher bases. If those values + /// are expected, use `to_str_radix_special()` instead. #[inline] fn to_str_radix(&self, rdx: uint) -> ~str { - to_str_radix(*self, rdx) + let (r, special) = strconv::float_to_str_common( + *self, rdx, true, strconv::SignNeg, strconv::DigAll); + if special { fail!("number has a special value, \ + try to_str_radix_special() if those are expected") } + r } } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 91361a61c21..52e74d969eb 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -788,29 +788,6 @@ pub fn to_str_hex(num: f64) -> ~str { } /// -/// Converts a float to a string in a given radix -/// -/// # Arguments -/// -/// * num - The float value -/// * radix - The base to use -/// -/// # Failure -/// -/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to -/// possible misinterpretation of the result at higher bases. If those values -/// are expected, use `to_str_radix_special()` instead. -/// -#[inline] -pub fn to_str_radix(num: f64, rdx: uint) -> ~str { - let (r, special) = strconv::float_to_str_common( - num, rdx, true, strconv::SignNeg, strconv::DigAll); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r -} - -/// /// Converts a float to a string in a given radix, and a flag indicating /// whether it's a special value /// @@ -863,9 +840,25 @@ impl to_str::ToStr for f64 { } impl num::ToStrRadix for f64 { + /// Converts a float to a string in a given radix + /// + /// # Arguments + /// + /// * num - The float value + /// * radix - The base to use + /// + /// # Failure + /// + /// Fails if called on a special value like `inf`, `-inf` or `NaN` due to + /// possible misinterpretation of the result at higher bases. If those values + /// are expected, use `to_str_radix_special()` instead. #[inline] fn to_str_radix(&self, rdx: uint) -> ~str { - to_str_radix(*self, rdx) + let (r, special) = strconv::float_to_str_common( + *self, rdx, true, strconv::SignNeg, strconv::DigAll); + if special { fail!("number has a special value, \ + try to_str_radix_special() if those are expected") } + r } } diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index 486d3562089..20c7adbd62c 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -112,29 +112,6 @@ pub fn to_str_hex(num: float) -> ~str { } /// -/// Converts a float to a string in a given radix -/// -/// # Arguments -/// -/// * num - The float value -/// * radix - The base to use -/// -/// # Failure -/// -/// Fails if called on a special value like `inf`, `-inf` or `NaN` due to -/// possible misinterpretation of the result at higher bases. If those values -/// are expected, use `to_str_radix_special()` instead. -/// -#[inline] -pub fn to_str_radix(num: float, radix: uint) -> ~str { - let (r, special) = strconv::float_to_str_common( - num, radix, true, strconv::SignNeg, strconv::DigAll); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r -} - -/// /// Converts a float to a string in a given radix, and a flag indicating /// whether it's a special value /// @@ -187,9 +164,25 @@ impl to_str::ToStr for float { } impl num::ToStrRadix for float { + /// Converts a float to a string in a given radix + /// + /// # Arguments + /// + /// * num - The float value + /// * radix - The base to use + /// + /// # Failure + /// + /// Fails if called on a special value like `inf`, `-inf` or `NaN` due to + /// possible misinterpretation of the result at higher bases. If those values + /// are expected, use `to_str_radix_special()` instead. #[inline] fn to_str_radix(&self, radix: uint) -> ~str { - to_str_radix(*self, radix) + let (r, special) = strconv::float_to_str_common( + *self, radix, true, strconv::SignNeg, strconv::DigAll); + if special { fail!("number has a special value, \ + try to_str_radix_special() if those are expected") } + r } } @@ -1342,8 +1335,8 @@ mod tests { #[test] pub fn test_to_str_radix() { - assert_eq!(to_str_radix(36., 36u), ~"10"); - assert_eq!(to_str_radix(8.125, 2u), ~"1000.001"); + assert_eq!(36.0f.to_str_radix(36u), ~"10"); + assert_eq!(8.125f.to_str_radix(2u), ~"1000.001"); } #[test] |
