示例#1
0
文件: RatNum.cs 项目: tspring/ioke
        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)));
        }
示例#2
0
文件: RatNum.cs 项目: tspring/ioke
 public override IntNum toExactInt(int rounding_mode)
 {
     return(IntNum.quotient(numerator(), denominator(), rounding_mode));
 }