/**
  * division of rational values
  * <p>
  * definition: `(n1 / d1) / (n2 / d2) = (n1 * d2) / (d1 * n2)`
  * <p>
  * @param that
  *            the value to divide this by
  * @return the ratio of this to that
  * @throws InvalidOperationException
  *             if that is null or if the numerator of that is 0
  */
 public RationalBase Div(RationalBase that)
 {
     if (that == null || that.Numerator == 0)
     {
         throw new InvalidOperationException();
     }
     return(Construct(this.Numerator * that.Denominator, this.Denominator * that.Numerator));
 }
 /**
  * addition of rational values
  * <p>
  * definition: `(n1 / d1) + (n2 / d2) = ((n1 * d2) + (n2 * d1)) / (d1 * d2)`
  *
  * @param that
  *            the value to add to this
  * @return the sum of this and that
  * @throws InvalidOperationException
  *             if that is null
  */
 public RationalBase Add(RationalBase that)
 {
     if (that == null)
     {
         throw new InvalidOperationException();
     }
     return(Construct((this.Numerator * that.Denominator) + (that.Numerator * this.Denominator), (this.Denominator * that.Denominator)));
 }
示例#3
0
        /**
         * subtraction of rational values
         * <p>
         * definition: `(n1 / d1) - (n2 / d2) = ((n1 * d2) - (n2 * d1)) / (d1 * d2)`
         *
         * @param that
         *            the value to subtract from this
         * @return the difference between this and that
         * @throws InvalidOperationException
         *             if that is null
         */
        public RationalBase Sub(RationalBase that)
        {
            if (that == null)
            {
                throw new InvalidOperationException();
            }

            return(Construct(((Numerator * that.Denominator) - (that.Numerator * Denominator)), (Denominator * that.Denominator)));
        }
示例#4
0
 /**
  * subtraction of rational values
  * <p>
  * definition: `(n1 / d1) - (n2 / d2) = ((n1 * d2) - (n2 * d1)) / (d1 * d2)`
  *
  * @param that
  *            the value to subtract from this
  * @return the difference between this and that
  * @throws InvalidOperationException
  *             if that is null
  */
 public RationalBase Sub(RationalBase that)
 {
     throw new NotImplementedException();
 }