diff --git a/src/lib.rs b/src/lib.rs index fecfa75..de7e3af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,24 +33,28 @@ impl Fraction { let mut new = Fraction { num, den }; new.reduce(); + new.correct_sign(); Ok(new) } pub fn reciprocal(&self) -> Result { - todo!() + Fraction::new(self.den, self.num) } pub fn abs(&self) -> Self { - todo!() + Fraction { + num: self.num.abs(), + den: self.den, + } } pub fn is_zero(&self) -> bool { - todo!() + self.num == 0 } pub fn is_integer(&self) -> bool { - todo!() + self.den == 1 } fn gcd(a: i64, b: i64) -> i64 {