public override bool Equals(object obj) { if (obj == null) { return(false); } if (!(obj is RationalNumber)) { return(false); } RationalNumber r = (RationalNumber)obj; if (r.numerator == this.numerator && r.denominator == this.denominator) { return(true); } return(false); }
public object MultiplyBy(RationalNumber factor) { return(RationalNumber.Create(this.numerator * factor.numerator, this.denominator * factor.denominator)); }
public object Subtract(RationalNumber number) { return(RationalNumber.Create((this.numerator * number.denominator) - (number.numerator * this.denominator), this.denominator * number.denominator)); }
public object SubtractFrom(long number) { return(RationalNumber.Create((number * this.denominator) - this.numerator, this.denominator)); }
public object Subtract(long number) { return(RationalNumber.Create(this.numerator - (number * this.denominator), this.denominator)); }
public object Add(RationalNumber number) { return(RationalNumber.Create((this.numerator * number.denominator) + (number.numerator * this.denominator), this.denominator * number.denominator)); }
public object Add(long number) { return(RationalNumber.Create(this.numerator + (number * this.denominator), this.denominator)); }
public object DivideBy(RationalNumber divisor) { return(RationalNumber.Create(this.numerator * divisor.denominator, this.denominator * divisor.numerator)); }
public object DivideTo(long divident) { return(RationalNumber.Create(this.denominator * divident, this.numerator)); }