code: protected void normalize() {
          /* compute greatest common divisor of numerator and denominator
           */
          final BigInteger g = a.gcd(b);
          if (g.compareTo(BigInteger.ONE) > 0) {
              a = a.divide(g);
              b = b.divide(g);
          }
          if (b.compareTo(BigInteger.ZERO) == -1) {
              a = a.negate();
              b = b.negate();
          }
      }
docs: Normalize to coprime numerator and denominator.
  Also copy a negative sign of the denominator to the numerator.