code: public static Fraction getReducedFraction(int numerator, int denominator) {
          if (denominator == 0) {
              throw new ArithmeticException("The denominator must not be zero");
          }
          if (numerator == 0) {
              return ZERO; // normalize zero.
          }
          // allow 2^k/-2^31 as a valid fraction (where k>0)
          if (denominator == Integer.MIN_VALUE && (numerator & 1) == 0) {
              numerator /= 2;
              denominator /= 2;
          }
          if (denominator < 0) {
              if (numerator == Integer.MIN_VALUE || denominator == Integer.MIN_VALUE) {
                  throw new ArithmeticException("overflow: can't negate");
              }
              numerator = -numerator;
              denominator = -denominator;
          }
          // simplify fraction.
          final int gcd = greatestCommonDivisor(numerator, denominator);
          numerator /= gcd;
          denominator /= gcd;
          return new Fraction(numerator, denominator);
      }
docs: <p>Creates a reduced <code>Fraction</code> instance with the 2 parts
  of a fraction Y/Z.</p>
  
  <p>For example, if the input parameters represent 2/4, then the created
  fraction will be 1/2.</p>
  
  <p>Any negative signs are resolved to be on the numerator.</p>
  
  @param numerator  the numerator, for example the three in 'three sevenths'
  @param denominator  the denominator, for example the seven in 'three sevenths'
  @return a new fraction instance, with the numerator and denominator reduced
  @throws ArithmeticException if the denominator is <code>zero</code>