コード例 #1
0
ファイル: RatNum.cs プロジェクト: vic/ioke-outdated
 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));
 }