]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/num/flt2dec/decoder.rs
Auto merge of #35856 - phimuemue:master, r=brson
[rust.git] / src / libcore / num / flt2dec / decoder.rs
index 6265691bde9e9ff278c1d73aa50b76d02653b4ca..276667e44aae1a42c65a91e14d2225d805fff8db 100644 (file)
 
 //! Decodes a floating-point value into individual parts and error ranges.
 
-use prelude::v1::*;
-
 use {f32, f64};
-use num::{Float, FpCategory};
+use num::FpCategory;
+use num::dec2flt::rawfp::RawFloat;
 
 /// Decoded unsigned finite value, such that:
 ///
@@ -52,7 +51,7 @@ pub enum FullDecoded {
 }
 
 /// A floating point type which can be `decode`d.
-pub trait DecodableFloat: Float + Copy {
+pub trait DecodableFloat: RawFloat + Copy {
     /// The minimum positive normalized value.
     fn min_pos_norm_value() -> Self;
 }
@@ -68,7 +67,7 @@ fn min_pos_norm_value() -> Self { f64::MIN_POSITIVE }
 /// Returns a sign (true when negative) and `FullDecoded` value
 /// from given floating point number.
 pub fn decode<T: DecodableFloat>(v: T) -> (/*negative?*/ bool, FullDecoded) {
-    let (mant, exp, sign) = v.integer_decode();
+    let (mant, exp, sign) = v.integer_decode2();
     let even = (mant & 1) == 0;
     let decoded = match v.classify() {
         FpCategory::Nan => FullDecoded::Nan,
@@ -82,7 +81,7 @@ pub fn decode<T: DecodableFloat>(v: T) -> (/*negative?*/ bool, FullDecoded) {
                                           exp: exp, inclusive: even })
         }
         FpCategory::Normal => {
-            let minnorm = <T as DecodableFloat>::min_pos_norm_value().integer_decode();
+            let minnorm = <T as DecodableFloat>::min_pos_norm_value().integer_decode2();
             if mant == minnorm.0 {
                 // neighbors: (maxmant, exp - 1) -- (minnormmant, exp) -- (minnormmant + 1, exp)
                 // where maxmant = minnormmant * 2 - 1