]> git.lizzy.rs Git - rust.git/commitdiff
run rustfmt on libcore/num folder
authorSrinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com>
Wed, 12 Oct 2016 18:27:46 +0000 (23:57 +0530)
committerSrinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com>
Wed, 12 Oct 2016 18:27:46 +0000 (23:57 +0530)
src/libcore/num/bignum.rs
src/libcore/num/diy_float.rs
src/libcore/num/f32.rs
src/libcore/num/f64.rs
src/libcore/num/mod.rs
src/libcore/num/wrapping.rs

index 1ca550c67463c3606c8db65c78577235ca283feb..a1f4630c304bf93dff849a7d479910658e085a43 100644 (file)
 pub trait FullOps: Sized {
     /// Returns `(carry', v')` such that `carry' * 2^W + v' = self + other + carry`,
     /// where `W` is the number of bits in `Self`.
-    fn full_add(self, other: Self, carry: bool) -> (bool /*carry*/, Self);
+    fn full_add(self, other: Self, carry: bool) -> (bool /* carry */, Self);
 
     /// Returns `(carry', v')` such that `carry' * 2^W + v' = self * other + carry`,
     /// where `W` is the number of bits in `Self`.
-    fn full_mul(self, other: Self, carry: Self) -> (Self /*carry*/, Self);
+    fn full_mul(self, other: Self, carry: Self) -> (Self /* carry */, Self);
 
     /// Returns `(carry', v')` such that `carry' * 2^W + v' = self * other + other2 + carry`,
     /// where `W` is the number of bits in `Self`.
-    fn full_mul_add(self, other: Self, other2: Self, carry: Self) -> (Self /*carry*/, Self);
+    fn full_mul_add(self, other: Self, other2: Self, carry: Self) -> (Self /* carry */, Self);
 
     /// Returns `(quo, rem)` such that `borrow * 2^W + self = quo * other + rem`
     /// and `0 <= rem < other`, where `W` is the number of bits in `Self`.
-    fn full_div_rem(self, other: Self, borrow: Self) -> (Self /*quotient*/, Self /*remainder*/);
+    fn full_div_rem(self,
+                    other: Self,
+                    borrow: Self)
+                    -> (Self /* quotient */, Self /* remainder */);
 }
 
 macro_rules! impl_full_ops {
@@ -100,11 +103,7 @@ fn full_div_rem(self, other: $ty, borrow: $ty) -> ($ty, $ty) {
 
 /// Table of powers of 5 representable in digits. Specifically, the largest {u8, u16, u32} value
 /// that's a power of five, plus the corresponding exponent. Used in `mul_pow5`.
-const SMALL_POW5: [(u64, usize); 3] = [
-    (125, 3),
-    (15625, 6),
-    (1_220_703_125, 13),
-];
+const SMALL_POW5: [(u64, usize); 3] = [(125, 3), (15625, 6), (1_220_703_125, 13)];
 
 macro_rules! define_bignum {
     ($name:ident: type=$ty:ty, n=$n:expr) => (
index 7c369ee3b3bd7b4291fe2a2011651cd5751eb301..11eea753f93f912a579dd607cddae2e39f61eb24 100644 (file)
@@ -49,12 +49,30 @@ pub fn mul(&self, other: &Fp) -> Fp {
     pub fn normalize(&self) -> Fp {
         let mut f = self.f;
         let mut e = self.e;
-        if f >> (64 - 32) == 0 { f <<= 32; e -= 32; }
-        if f >> (64 - 16) == 0 { f <<= 16; e -= 16; }
-        if f >> (64 -  8) == 0 { f <<=  8; e -=  8; }
-        if f >> (64 -  4) == 0 { f <<=  4; e -=  4; }
-        if f >> (64 -  2) == 0 { f <<=  2; e -=  2; }
-        if f >> (64 -  1) == 0 { f <<=  1; e -=  1; }
+        if f >> (64 - 32) == 0 {
+            f <<= 32;
+            e -= 32;
+        }
+        if f >> (64 - 16) == 0 {
+            f <<= 16;
+            e -= 16;
+        }
+        if f >> (64 - 8) == 0 {
+            f <<= 8;
+            e -= 8;
+        }
+        if f >> (64 - 4) == 0 {
+            f <<= 4;
+            e -= 4;
+        }
+        if f >> (64 - 2) == 0 {
+            f <<= 2;
+            e -= 2;
+        }
+        if f >> (64 - 1) == 0 {
+            f <<= 1;
+            e -= 1;
+        }
         debug_assert!(f >= (1 >> 63));
         Fp { f: f, e: e }
     }
@@ -66,6 +84,9 @@ pub fn normalize_to(&self, e: i16) -> Fp {
         assert!(edelta >= 0);
         let edelta = edelta as usize;
         assert_eq!(self.f << edelta >> edelta, self.f);
-        Fp { f: self.f << edelta, e: e }
+        Fp {
+            f: self.f << edelta,
+            e: e,
+        }
     }
 }
index 07b05f91f489f9ecfa3752b2175e5f0bc35a3251..4527d46a27d8a9590f6e64ebdf0376ae561996d6 100644 (file)
 
 /// Not a Number (NaN).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NAN: f32 = 0.0_f32/0.0_f32;
+pub const NAN: f32 = 0.0_f32 / 0.0_f32;
 /// Infinity (∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const INFINITY: f32 = 1.0_f32/0.0_f32;
+pub const INFINITY: f32 = 1.0_f32 / 0.0_f32;
 /// Negative infinity (-∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NEG_INFINITY: f32 = -1.0_f32/0.0_f32;
+pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32;
 
 /// Basic mathematical constants.
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -144,26 +144,40 @@ pub mod consts {
            issue = "32110")]
 impl Float for f32 {
     #[inline]
-    fn nan() -> f32 { NAN }
+    fn nan() -> f32 {
+        NAN
+    }
 
     #[inline]
-    fn infinity() -> f32 { INFINITY }
+    fn infinity() -> f32 {
+        INFINITY
+    }
 
     #[inline]
-    fn neg_infinity() -> f32 { NEG_INFINITY }
+    fn neg_infinity() -> f32 {
+        NEG_INFINITY
+    }
 
     #[inline]
-    fn zero() -> f32 { 0.0 }
+    fn zero() -> f32 {
+        0.0
+    }
 
     #[inline]
-    fn neg_zero() -> f32 { -0.0 }
+    fn neg_zero() -> f32 {
+        -0.0
+    }
 
     #[inline]
-    fn one() -> f32 { 1.0 }
+    fn one() -> f32 {
+        1.0
+    }
 
     /// Returns `true` if the number is NaN.
     #[inline]
-    fn is_nan(self) -> bool { self != self }
+    fn is_nan(self) -> bool {
+        self != self
+    }
 
     /// Returns `true` if the number is infinite.
     #[inline]
@@ -192,11 +206,11 @@ fn classify(self) -> Fp {
 
         let bits: u32 = unsafe { mem::transmute(self) };
         match (bits & MAN_MASK, bits & EXP_MASK) {
-            (0, 0)        => Fp::Zero,
-            (_, 0)        => Fp::Subnormal,
+            (0, 0) => Fp::Zero,
+            (_, 0) => Fp::Subnormal,
             (0, EXP_MASK) => Fp::Infinite,
             (_, EXP_MASK) => Fp::Nan,
-            _             => Fp::Normal,
+            _ => Fp::Normal,
         }
     }
 
@@ -252,7 +266,9 @@ fn is_sign_negative(self) -> bool {
 
     /// Returns the reciprocal (multiplicative inverse) of the number.
     #[inline]
-    fn recip(self) -> f32 { 1.0 / self }
+    fn recip(self) -> f32 {
+        1.0 / self
+    }
 
     #[inline]
     fn powi(self, n: i32) -> f32 {
@@ -261,7 +277,9 @@ fn powi(self, n: i32) -> f32 {
 
     /// Converts to degrees, assuming the number is in radians.
     #[inline]
-    fn to_degrees(self) -> f32 { self * (180.0f32 / consts::PI) }
+    fn to_degrees(self) -> f32 {
+        self * (180.0f32 / consts::PI)
+    }
 
     /// Converts to radians, assuming the number is in degrees.
     #[inline]
index 82a09e599e027a49065a342fcaac64fd31da2a79..991a856834948687cf00c59d5879149733af6bc6 100644 (file)
 
 /// Not a Number (NaN).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NAN: f64 = 0.0_f64/0.0_f64;
+pub const NAN: f64 = 0.0_f64 / 0.0_f64;
 /// Infinity (∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const INFINITY: f64 = 1.0_f64/0.0_f64;
+pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
 /// Negative infinity (-∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NEG_INFINITY: f64 = -1.0_f64/0.0_f64;
+pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
 
 /// Basic mathematical constants.
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -144,26 +144,40 @@ pub mod consts {
            issue = "32110")]
 impl Float for f64 {
     #[inline]
-    fn nan() -> f64 { NAN }
+    fn nan() -> f64 {
+        NAN
+    }
 
     #[inline]
-    fn infinity() -> f64 { INFINITY }
+    fn infinity() -> f64 {
+        INFINITY
+    }
 
     #[inline]
-    fn neg_infinity() -> f64 { NEG_INFINITY }
+    fn neg_infinity() -> f64 {
+        NEG_INFINITY
+    }
 
     #[inline]
-    fn zero() -> f64 { 0.0 }
+    fn zero() -> f64 {
+        0.0
+    }
 
     #[inline]
-    fn neg_zero() -> f64 { -0.0 }
+    fn neg_zero() -> f64 {
+        -0.0
+    }
 
     #[inline]
-    fn one() -> f64 { 1.0 }
+    fn one() -> f64 {
+        1.0
+    }
 
     /// Returns `true` if the number is NaN.
     #[inline]
-    fn is_nan(self) -> bool { self != self }
+    fn is_nan(self) -> bool {
+        self != self
+    }
 
     /// Returns `true` if the number is infinite.
     #[inline]
@@ -192,11 +206,11 @@ fn classify(self) -> Fp {
 
         let bits: u64 = unsafe { mem::transmute(self) };
         match (bits & MAN_MASK, bits & EXP_MASK) {
-            (0, 0)        => Fp::Zero,
-            (_, 0)        => Fp::Subnormal,
+            (0, 0) => Fp::Zero,
+            (_, 0) => Fp::Subnormal,
             (0, EXP_MASK) => Fp::Infinite,
             (_, EXP_MASK) => Fp::Nan,
-            _             => Fp::Normal,
+            _ => Fp::Normal,
         }
     }
 
@@ -252,7 +266,9 @@ fn is_sign_negative(self) -> bool {
 
     /// Returns the reciprocal (multiplicative inverse) of the number.
     #[inline]
-    fn recip(self) -> f64 { 1.0 / self }
+    fn recip(self) -> f64 {
+        1.0 / self
+    }
 
     #[inline]
     fn powi(self, n: i32) -> f64 {
@@ -261,7 +277,9 @@ fn powi(self, n: i32) -> f64 {
 
     /// Converts to degrees, assuming the number is in radians.
     #[inline]
-    fn to_degrees(self) -> f64 { self * (180.0f64 / consts::PI) }
+    fn to_degrees(self) -> f64 {
+        self * (180.0f64 / consts::PI)
+    }
 
     /// Converts to radians, assuming the number is in degrees.
     #[inline]
index 516d6f7c4a0bd956d978b8090e9fc2e9bd78f844..a4529909e83ef61ddbd82d2fb5586ca317c98308 100644 (file)
@@ -43,7 +43,8 @@
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
 #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
-pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
+pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")]
+                       pub T);
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: fmt::Debug> fmt::Debug for Wrapping<T> {
@@ -2402,7 +2403,7 @@ pub enum FpCategory {
 
     /// Positive or negative infinity.
     #[stable(feature = "rust1", since = "1.0.0")]
-    Infinite ,
+    Infinite,
 
     /// Positive or negative zero.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -2662,8 +2663,7 @@ fn checked_add(&self, other: u32) -> Option<Self> {
 }
 doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
 
-fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32)
-                                         -> Result<T, ParseIntError> {
+fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, ParseIntError> {
     use self::IntErrorKind::*;
     use self::ParseIntError as PIE;
 
@@ -2686,7 +2686,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32)
     let (is_positive, digits) = match src[0] {
         b'+' => (true, &src[1..]),
         b'-' if is_signed_ty => (false, &src[1..]),
-        _ => (true, src)
+        _ => (true, src),
     };
 
     if digits.is_empty() {
@@ -2738,7 +2738,9 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32)
 /// [`i8::from_str_radix()`]: ../../std/primitive.i8.html#method.from_str_radix
 #[derive(Debug, Clone, PartialEq, Eq)]
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct ParseIntError { kind: IntErrorKind }
+pub struct ParseIntError {
+    kind: IntErrorKind,
+}
 
 #[derive(Debug, Clone, PartialEq, Eq)]
 enum IntErrorKind {
index 2c69880dfa35ab4417808f8e8c62bafbfaef0062..d35c451ac2604471de90bf2426d18d528fde1486 100644 (file)
@@ -310,13 +310,13 @@ mod platform {
         pub const isize: u32 = super::i64;
     }
 
-    pub const  i8: u32 = (1 << 3) - 1;
+    pub const i8: u32 = (1 << 3) - 1;
     pub const i16: u32 = (1 << 4) - 1;
     pub const i32: u32 = (1 << 5) - 1;
     pub const i64: u32 = (1 << 6) - 1;
     pub use self::platform::isize;
 
-    pub const  u8: u32 = i8;
+    pub const u8: u32 = i8;
     pub const u16: u32 = i16;
     pub const u32: u32 = i32;
     pub const u64: u32 = i64;