guava/src/com/google/common/math/LongMath.java
static long multiplyFraction(long x, long numerator, long denominator) {
    if (x == 1) {
      return numerator / denominator;
    }
    long commonDivisor = gcd(x, denominator);
    x /= commonDivisor;
    denominator /= commonDivisor;
    // We know gcd(x, denominator) = 1, and x * numerator / denominator is exact,
    // so denominator must be a divisor of numerator.
    return x * (numerator / denominator);
  }
static long multiplyFraction(long x, long numerator, long denominator) {
    if (x == 1) {
      return numerator / denominator;
    }
    long commonDivisor = gcd(x, denominator);
    x /= commonDivisor;
    denominator /= commonDivisor;
    // We know gcd(x, denominator) = 1, and x * numerator / denominator is exact,
    // so denominator must be a divisor of numerator.
    return x * (numerator / denominator);
  }
static long multiplyFraction ( long x , long numerator , long denominator ) { if ( x == 1 ) { return numerator / denominator ; } long commonDivisor = gcd ( x , denominator ) ; x /= commonDivisor ; denominator /= commonDivisor ; // We know gcd(x, denominator) = 1, and x * numerator / denominator is exact, // so denominator must be a divisor of numerator. return x * ( numerator / denominator ) ; }
Returns (x * numerator / denominator), which is assumed to come out to an integral value.
Returns ( x * numerator / denominator ) which is assumed to come out to an integral value .