public static RatNum make(IntNum num, IntNum den) { IntNum g = IntNum.gcd(num, den); if (den.isNegative()) { g = IntNum.neg(g); } if (!g.isOne()) { num = IntNum.quotient(num, g); den = IntNum.quotient(den, g); } return(den.isOne() ? (RatNum)num : (RatNum)(new IntFraction(num, den))); }
public override IntNum toExactInt(int rounding_mode) { return(IntNum.quotient(numerator(), denominator(), rounding_mode)); }