relp_num/rational/big/ops/
mod.rs1use std::iter::Sum;
2use std::ops::Neg;
3
4use crate::integer::big::ops::div::div as div_by_odd_or_even;
5use crate::integer::big::ops::normalize::gcd;
6use crate::Negateable;
7use crate::rational::big::Big;
8
9mod add_sub;
10mod mul_div;
11pub(super) mod building_blocks;
12
13impl<const S: usize> Sum for Big<S> {
14 #[inline]
15 fn sum<I: Iterator<Item=Self>>(mut iter: I) -> Self {
16 let first = iter.next();
17 match first {
18 None => <Self as num_traits::Zero>::zero(),
19 Some(mut total) => {
20 for next_value in iter {
21 total += next_value;
22 }
23
24 total
25 }
26 }
27 }
28}
29
30impl<const S: usize> Neg for Big<S> {
31 type Output = Self;
32
33 #[inline]
34 fn neg(mut self) -> Self::Output {
35 self.sign.negate();
36 self
37 }
38}
39
40impl<const S: usize> Neg for &Big<S> {
41 type Output = Big<S>;
42
43 #[inline]
44 fn neg(self) -> Self::Output {
45 Self::Output {
46 sign: !self.sign,
47 numerator: self.numerator.clone(),
48 denominator: self.denominator.clone(),
49 }
50 }
51}
52
53#[cfg(test)]
54mod test;