diff options
Diffstat (limited to 'src/libstd/num/f32.rs')
| -rw-r--r-- | src/libstd/num/f32.rs | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index c87becd741e..30bee80fbf6 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -18,7 +18,7 @@ use core::num; use intrinsics; use libc::c_int; -use num::{FpCategory, ParseFloatError}; +use num::FpCategory; #[stable(feature = "rust1", since = "1.0.0")] pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON}; @@ -126,16 +126,6 @@ mod cmath { #[cfg(not(test))] #[lang = "f32"] impl f32 { - /// Parses a float as with a given radix - #[unstable(feature = "float_from_str_radix", reason = "recently moved API", - issue = "27736")] - #[rustc_deprecated(since = "1.4.0", - reason = "unclear how useful or correct this is")] - #[allow(deprecated)] - pub fn from_str_radix(s: &str, radix: u32) -> Result<f32, ParseFloatError> { - num::Float::from_str_radix(s, radix) - } - /// Returns `true` if this value is `NaN` and false otherwise. /// /// ``` @@ -1712,11 +1702,9 @@ mod tests { #[test] fn test_ldexp() { - // We have to use from_str until base-2 exponents - // are supported in floating-point literals - let f1: f32 = f32::from_str_radix("1p-123", 16).unwrap(); - let f2: f32 = f32::from_str_radix("1p-111", 16).unwrap(); - let f3: f32 = f32::from_str_radix("1.Cp-12", 16).unwrap(); + let f1 = 2.0f32.powi(-123); + let f2 = 2.0f32.powi(-111); + let f3 = 1.75 * 2.0f32.powi(-12); assert_eq!(f32::ldexp(1f32, -123), f1); assert_eq!(f32::ldexp(1f32, -111), f2); assert_eq!(f32::ldexp(1.75f32, -12), f3); @@ -1734,11 +1722,9 @@ mod tests { #[test] fn test_frexp() { - // We have to use from_str until base-2 exponents - // are supported in floating-point literals - let f1: f32 = f32::from_str_radix("1p-123", 16).unwrap(); - let f2: f32 = f32::from_str_radix("1p-111", 16).unwrap(); - let f3: f32 = f32::from_str_radix("1.Cp-123", 16).unwrap(); + let f1 = 2.0f32.powi(-123); + let f2 = 2.0f32.powi(-111); + let f3 = 1.75 * 2.0f32.powi(-123); let (x1, exp1) = f1.frexp(); let (x2, exp2) = f2.frexp(); let (x3, exp3) = f3.frexp(); |
