Пример #1
0
 public static RatNum add(RatNum paramRatNum1, RatNum paramRatNum2, int paramInt) {
   IntNum localIntNum1 = paramRatNum1.numerator();
   paramRatNum1 = paramRatNum1.denominator();
   IntNum localIntNum2 = paramRatNum2.numerator();
   paramRatNum2 = paramRatNum2.denominator();
   if (IntNum.equals(paramRatNum1, paramRatNum2)) {
     return make(IntNum.add(localIntNum1, localIntNum2, paramInt), paramRatNum1);
   }
   return make(
       IntNum.add(
           IntNum.times(paramRatNum2, localIntNum1),
           IntNum.times(localIntNum2, paramRatNum1),
           paramInt),
       IntNum.times(paramRatNum1, paramRatNum2));
 }
Пример #2
0
 public static RatNum neg(RatNum paramRatNum) {
   IntNum localIntNum = paramRatNum.numerator();
   paramRatNum = paramRatNum.denominator();
   return make(IntNum.neg(localIntNum), paramRatNum);
 }
Пример #3
0
 public static RatNum divide(RatNum paramRatNum1, RatNum paramRatNum2) {
   return make(
       IntNum.times(paramRatNum1.numerator(), paramRatNum2.denominator()),
       IntNum.times(paramRatNum1.denominator(), paramRatNum2.numerator()));
 }
Пример #4
0
 public static boolean equals(RatNum paramRatNum1, RatNum paramRatNum2) {
   return (IntNum.equals(paramRatNum1.numerator(), paramRatNum2.numerator()))
       && (IntNum.equals(paramRatNum1.denominator(), paramRatNum2.denominator()));
 }
Пример #5
0
 public static int compare(RatNum paramRatNum1, RatNum paramRatNum2) {
   return IntNum.compare(
       IntNum.times(paramRatNum1.numerator(), paramRatNum2.denominator()),
       IntNum.times(paramRatNum2.numerator(), paramRatNum1.denominator()));
 }