X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_apfloat%2Fppc.rs;h=e0b306ac47cc4c34527507ee00309186437d5716;hb=1cbb5d849071970f7a4d19ce8f75becaac4ee0c2;hp=8e2e390568e48261e5e0ea262dfd89a64ad07bc4;hpb=9860a4eeb7e555b3a137b2aa0cde818d44a608dc;p=rust.git diff --git a/src/librustc_apfloat/ppc.rs b/src/librustc_apfloat/ppc.rs index 8e2e390568e..e0b306ac47c 100644 --- a/src/librustc_apfloat/ppc.rs +++ b/src/librustc_apfloat/ppc.rs @@ -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 { } } - (_, 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 { (_, 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 { - 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 { - 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 { - 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 { @@ -366,10 +356,7 @@ fn next_up(self) -> StatusAnd { 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 { @@ -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)) }