BigFraction extends Number implements FieldElement<BigFraction>, Comparable<BigFraction>, Serializable { public int compareTo(final BigFraction object) { BigInteger nOd = numerator.multiply(object.denominator); BigInteger dOn = denominator.multiply(object.numerator); return nOd.compareTo(dOn); } BigFraction(final BigInteger num);  BigFraction(BigInteger num, BigInteger den);  BigFraction(final double value);  BigFraction(final double value, final double epsilon,
                       final int maxIterations); private  BigFraction(final double value, final double epsilon,
                        final int maxDenominator, int maxIterations);  BigFraction(final double value, final int maxDenominator);  BigFraction(final int num);  BigFraction(final int num, final int den);  BigFraction(final long num);  BigFraction(final long num, final long den); static BigFraction getReducedFraction(final int numerator,
                                                 final int denominator); BigFraction abs(); BigFraction add(final BigInteger bg); BigFraction add(final int i); BigFraction add(final long l); BigFraction add(final BigFraction fraction); BigDecimal bigDecimalValue(); BigDecimal bigDecimalValue(final int roundingMode); BigDecimal bigDecimalValue(final int scale, final int roundingMode); int compareTo(final BigFraction object); BigFraction divide(final BigInteger bg); BigFraction divide(final int i); BigFraction divide(final long l); BigFraction divide(final BigFraction fraction); @Override double doubleValue(); @Override boolean equals(final Object other); @Override float floatValue(); BigInteger getDenominator(); int getDenominatorAsInt(); long getDenominatorAsLong(); BigInteger getNumerator(); int getNumeratorAsInt(); long getNumeratorAsLong(); @Override int hashCode(); @Override int intValue(); @Override long longValue(); BigFraction multiply(final BigInteger bg); BigFraction multiply(final int i); BigFraction multiply(final long l); BigFraction multiply(final BigFraction fraction); BigFraction negate(); double percentageValue(); BigFraction pow(final int exponent); BigFraction pow(final long exponent); BigFraction pow(final BigInteger exponent); double pow(final double exponent); BigFraction reciprocal(); BigFraction reduce(); BigFraction subtract(final BigInteger bg); BigFraction subtract(final int i); BigFraction subtract(final long l); BigFraction subtract(final BigFraction fraction); @Override String toString(); BigFractionField getField(); static final BigFraction TWO; static final BigFraction ONE; static final BigFraction ZERO; static final BigFraction MINUS_ONE; static final BigFraction FOUR_FIFTHS; static final BigFraction ONE_FIFTH; static final BigFraction ONE_HALF; static final BigFraction ONE_QUARTER; static final BigFraction ONE_THIRD; static final BigFraction THREE_FIFTHS; static final BigFraction THREE_QUARTERS; static final BigFraction TWO_FIFTHS; static final BigFraction TWO_QUARTERS; static final BigFraction TWO_THIRDS; }
@Test public void testCompareTo() { BigFraction first = new BigFraction(1, 2); BigFraction second = new BigFraction(1, 3); BigFraction third = new BigFraction(1, 2); Assert.assertEquals(0, first.compareTo(first)); Assert.assertEquals(0, first.compareTo(third)); Assert.assertEquals(1, first.compareTo(second)); Assert.assertEquals(-1, second.compareTo(first)); BigFraction pi1 = new BigFraction(1068966896, 340262731); BigFraction pi2 = new BigFraction( 411557987, 131002976); Assert.assertEquals(-1, pi1.compareTo(pi2)); Assert.assertEquals( 1, pi2.compareTo(pi1)); Assert.assertEquals(0.0, pi1.doubleValue() - pi2.doubleValue(), 1.0e-20); }