]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_apfloat/ppc.rs
Clear out std, not std tools
[rust.git] / src / librustc_apfloat / ppc.rs
index 8e2e390568e48261e5e0ea262dfd89a64ad07bc4..e0b306ac47cc4c34527507ee00309186437d5716 100644 (file)
@@ -1,5 +1,5 @@
-use crate::{Category, ExpInt, Float, FloatConvert, Round, ParseError, Status, StatusAnd};
 use crate::ieee;
+use crate::{Category, ExpInt, Float, FloatConvert, ParseError, Round, Status, StatusAnd};
 
 use core::cmp::Ordering;
 use core::fmt;
@@ -165,10 +165,7 @@ fn largest() -> Self {
     const SMALLEST: Self = DoubleFloat(F::SMALLEST, F::ZERO);
 
     fn smallest_normalized() -> Self {
-        DoubleFloat(
-            F::smallest_normalized().scalbn(F::PRECISION as ExpInt),
-            F::ZERO,
-        )
+        DoubleFloat(F::smallest_normalized().scalbn(F::PRECISION as ExpInt), F::ZERO)
     }
 
     // Implement addition, subtraction, multiplication and division based on:
@@ -185,13 +182,13 @@ fn add_r(mut self, rhs: Self, round: Round) -> StatusAnd<Self> {
                 }
             }
 
-            (_, Category::Zero) |
-            (Category::NaN, _) |
-            (Category::Infinity, Category::Normal) => Status::OK.and(self),
+            (_, Category::Zero) | (Category::NaN, _) | (Category::Infinity, Category::Normal) => {
+                Status::OK.and(self)
+            }
 
-            (Category::Zero, _) |
-            (_, Category::NaN) |
-            (_, Category::Infinity) => Status::OK.and(rhs),
+            (Category::Zero, _) | (_, Category::NaN) | (_, Category::Infinity) => {
+                Status::OK.and(rhs)
+            }
 
             (Category::Normal, Category::Normal) => {
                 let mut status = Status::OK;
@@ -287,14 +284,13 @@ fn mul_r(mut self, rhs: Self, round: Round) -> StatusAnd<Self> {
 
             (_, Category::NaN) => Status::OK.and(rhs),
 
-            (Category::Zero, Category::Infinity) |
-            (Category::Infinity, Category::Zero) => Status::OK.and(Self::NAN),
+            (Category::Zero, Category::Infinity) | (Category::Infinity, Category::Zero) => {
+                Status::OK.and(Self::NAN)
+            }
 
-            (Category::Zero, _) |
-            (Category::Infinity, _) => Status::OK.and(self),
+            (Category::Zero, _) | (Category::Infinity, _) => Status::OK.and(self),
 
-            (_, Category::Zero) |
-            (_, Category::Infinity) => Status::OK.and(rhs),
+            (_, Category::Zero) | (_, Category::Infinity) => Status::OK.and(rhs),
 
             (Category::Normal, Category::Normal) => {
                 let mut status = Status::OK;
@@ -343,21 +339,15 @@ fn mul_add_r(self, multiplicand: Self, addend: Self, round: Round) -> StatusAnd<
     }
 
     fn div_r(self, rhs: Self, round: Round) -> StatusAnd<Self> {
-        Fallback::from(self).div_r(Fallback::from(rhs), round).map(
-            Self::from,
-        )
+        Fallback::from(self).div_r(Fallback::from(rhs), round).map(Self::from)
     }
 
     fn c_fmod(self, rhs: Self) -> StatusAnd<Self> {
-        Fallback::from(self).c_fmod(Fallback::from(rhs)).map(
-            Self::from,
-        )
+        Fallback::from(self).c_fmod(Fallback::from(rhs)).map(Self::from)
     }
 
     fn round_to_integral(self, round: Round) -> StatusAnd<Self> {
-        Fallback::from(self).round_to_integral(round).map(
-            Self::from,
-        )
+        Fallback::from(self).round_to_integral(round).map(Self::from)
     }
 
     fn next_up(self) -> StatusAnd<Self> {
@@ -366,10 +356,7 @@ fn next_up(self) -> StatusAnd<Self> {
 
     fn from_bits(input: u128) -> Self {
         let (a, b) = (input, input >> F::BITS);
-        DoubleFloat(
-            F::from_bits(a & ((1 << F::BITS) - 1)),
-            F::from_bits(b & ((1 << F::BITS) - 1)),
-        )
+        DoubleFloat(F::from_bits(a & ((1 << F::BITS) - 1)), F::from_bits(b & ((1 << F::BITS) - 1)))
     }
 
     fn from_u128_r(input: u128, round: Round) -> StatusAnd<Self> {
@@ -394,11 +381,9 @@ fn cmp_abs_normal(self, rhs: Self) -> Ordering {
             if result != Ordering::Equal {
                 let against = self.0.is_negative() ^ self.1.is_negative();
                 let rhs_against = rhs.0.is_negative() ^ rhs.1.is_negative();
-                (!against).cmp(&!rhs_against).then_with(|| if against {
-                    result.reverse()
-                } else {
-                    result
-                })
+                (!against)
+                    .cmp(&!rhs_against)
+                    .then_with(|| if against { result.reverse() } else { result })
             } else {
                 result
             }
@@ -414,8 +399,8 @@ fn is_negative(self) -> bool {
     }
 
     fn is_denormal(self) -> bool {
-        self.category() == Category::Normal &&
-            (self.0.is_denormal() || self.0.is_denormal() ||
+        self.category() == Category::Normal
+            && (self.0.is_denormal() || self.0.is_denormal() ||
           // (double)(Hi + Lo) == Hi defines a normal number.
           !(self.0 + self.1).value.bitwise_eq(self.0))
     }