| Modifier and Type | Field and Description |
|---|---|
| private final BigInteger | denominator
The denominator. |
| public static final BigFraction | FOUR_FIFTHS
A fraction representing "4/5". |
| public static final BigFraction | MINUS_ONE
A fraction representing "-1 / 1". |
| private final BigInteger | numerator
The numerator. |
| public static final BigFraction | ONE
A fraction representing "1". |
| public static final BigFraction | ONE_FIFTH
A fraction representing "1/5". |
| public static final BigFraction | ONE_HALF
A fraction representing "1/2". |
| private static final BigInteger | ONE_HUNDRED
|
| public static final BigFraction | ONE_QUARTER
A fraction representing "1/4". |
| public static final BigFraction | ONE_THIRD
A fraction representing "1/3". |
| private static final long | serialVersionUID
Serializable version identifier.
|
| public static final BigFraction | THREE_FIFTHS
A fraction representing "3/5". |
| public static final BigFraction | THREE_QUARTERS
A fraction representing "3/4". |
| public static final BigFraction | TWO
A fraction representing "2 / 1". |
| public static final BigFraction | TWO_FIFTHS
A fraction representing "2/5". |
| public static final BigFraction | TWO_QUARTERS
A fraction representing "2/4". |
| public static final BigFraction | TWO_THIRDS
A fraction representing "2/3". |
| public static final BigFraction | ZERO
A fraction representing "0". |
| Access | Constructor and Description |
|---|---|
| public | BigFraction(final BigInteger
the numerator. num)
Create a |
| public | BigFraction(BigInteger
the numerator, must not be num, BigInteger null.the denominator, must not be den)null.Create a |
| public | BigFraction(final double
the double value to convert to a fraction. value)Create a fraction given the double value. |
| public | BigFraction(final double
the double value to convert to a fraction. value, final double maximum error allowed. The resulting fraction is within
epsilon, final int epsilon of value, in absolute terms.maximum number of convergents. maxIterations)Create a fraction given the double value and maximum error allowed. |
| private | BigFraction(final double
the double value to convert to a fraction. value, final double maximum error allowed. The resulting fraction is within
epsilon, final int epsilon of value, in absolute terms.maximum denominator value allowed. maxDenominator, int maximum number of convergents. maxIterations)Create a fraction given the double value and either the maximum error allowed or the maximum number of denominator digits. |
| public | BigFraction(final double
the double value to convert to a fraction. value, final int The maximum allowed value for denominator. maxDenominator)Create a fraction given the double value and maximum denominator. |
| public | BigFraction(final int
the numerator. num)
Create a |
| public | BigFraction(final int
the numerator. num, final int the denominator. den)
Create a |
| public | BigFraction(final long
the numerator. num)
Create a |
| public | BigFraction(final long
the numerator. num, final long the denominator. den)
Create a |
| Modifier and Type | Method and Description |
|---|---|
| public BigFraction | |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the bg)BigInteger to add, must'nt be null.Implements org.
Adds the value of this fraction to the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the i)integer to add.Implements org.
Adds the value of this fraction to the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the l)long to add.Implements org.
Adds the value of this fraction to the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the fraction)BigFraction to add, must not be null.Implements org. Adds the value of this fraction to another, returning the result in reduced form. |
| public BigDecimal | |
| public BigDecimal | Returns: the fraction as aBigDecimal.rounding mode to apply. see roundingMode)BigDecimal constants.
Gets the fraction as a |
| public BigDecimal | Returns: the fraction as aBigDecimal.scale of the scale, final int BigDecimal quotient to be returned.
see BigDecimal for more information.rounding mode to apply. see roundingMode)BigDecimal constants.
Gets the fraction as a |
| public int | Returns: -1 if this is less thanobject, +1 if this is greater
than object, 0 if they are equal.the object to compare to, must not be object)null.Implements java. Compares this object to another based on size. |
| public BigFraction | Returns: aBigFraction instance with the resulting valuesthe bg)BigInteger to divide by, must not be nullImplements org.
Divide the value of this fraction by the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting valuesthe i)int to divide byImplements org.
Divide the value of this fraction by the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting valuesthe l)long to divide byImplements org.
Divide the value of this fraction by the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting values.Fraction to divide by, must not be fraction)null.Implements org. Divide the value of this fraction by another, returning the result in reduced form. |
| public double | Returns: the fraction as adoubleImplements abstract java.
Gets the fraction as a |
| public boolean | Returns: true if two fractions are equal, false if object isnull, not an instance of BigFraction, or not
equal to this fraction instance.fraction to test for equality to this fraction, can be
other)null.Overrides java. Test for the equality of two fractions. |
| public float | Returns: the fraction as afloat.Implements abstract java.
Gets the fraction as a |
| public BigInteger | |
| public int | |
| public long | |
| public BigFractionField | getField()
Implements org. Get the |
| public BigInteger | |
| public int | |
| public long | |
| public static BigFraction | Returns: a new fraction instance, with the numerator and denominator reduced.the numerator, for example the three in 'three sevenths'. numerator, final int the denominator, for example the seven in 'three sevenths'. denominator)
Creates a |
| public int | Returns: a hash code value for this object.Overrides java. Gets a hashCode for the fraction. |
| public int | Returns: the whole number fraction part.Implements abstract java.
Gets the fraction as an |
| public long | Returns: the whole number fraction part.Implements abstract java.
Gets the fraction as a |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the bg)BigInteger to multiply by.Implements org.
Multiplies the value of this fraction by the passed
|
| public BigFraction | Returns: aBigFraction instance with the resulting values.the i)int to multiply by.Implements org.
Multiply the value of this fraction by the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the l)long to multiply by.Implements org.
Multiply the value of this fraction by the passed |
| public BigFraction | Returns: aBigFraction instance with the resulting values.Fraction to multiply by, must not be fraction)null.Implements org. Multiplies the value of this fraction by another, returning the result in reduced form. |
| public BigFraction | Returns: the negation of this fraction.Implements org. Return the additive inverse of this fraction, returning the result in reduced form. |
| public double | Returns: the fraction percentage as adouble.
Gets the fraction percentage as a |
| public BigFraction | Returns: thisexponent.exponent to which this exponent)BigFraction is to be
raised.
Returns a |
| public BigFraction | Returns: thisexponent as aBigFraction.exponent to which this exponent)BigFraction is to be raised.
Returns a |
| public BigFraction | Returns: thisexponent as aBigFraction.exponent to which this exponent)BigFraction is to be raised.
Returns a |
| public double | Returns: thisexponent.exponent to which this exponent)BigFraction is to be raised.
Returns a |
| public BigFraction | Returns: the reciprocal fraction.Implements org. Return the multiplicative inverse of this fraction. |
| public BigFraction | Returns: the reducedBigFraction. It doesn't change anything if
the fraction can be reduced.
Reduce this |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the bg)BigInteger to subtract, cannot be null.Implements org.
Subtracts the value of an |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the i)integer to subtract.Implements org.
Subtracts the value of an |
| public BigFraction | Returns: aBigFraction instance with the resulting values.the l)long to subtract.Implements org.
Subtracts the value of a |
| public BigFraction | Returns: aBigFraction instance with the resulting valuesBigFraction to subtract, must not be null.Implements org. Subtracts the value of another fraction from the value of this one, returning the result in reduced form. |
| public String | Returns: a string representation of the fraction.Overrides java.
Returns the |
| denominator | back to summary |
|---|---|
| private final BigInteger denominator The denominator. | |
| FOUR_FIFTHS | back to summary |
|---|---|
| public static final BigFraction FOUR_FIFTHS A fraction representing "4/5". | |
| MINUS_ONE | back to summary |
|---|---|
| public static final BigFraction MINUS_ONE A fraction representing "-1 / 1". | |
| numerator | back to summary |
|---|---|
| private final BigInteger numerator The numerator. | |
| ONE | back to summary |
|---|---|
| public static final BigFraction ONE A fraction representing "1". | |
| ONE_FIFTH | back to summary |
|---|---|
| public static final BigFraction ONE_FIFTH A fraction representing "1/5". | |
| ONE_HALF | back to summary |
|---|---|
| public static final BigFraction ONE_HALF A fraction representing "1/2". | |
| ONE_HUNDRED | back to summary |
|---|---|
| private static final BigInteger ONE_HUNDRED
| |
| ONE_QUARTER | back to summary |
|---|---|
| public static final BigFraction ONE_QUARTER A fraction representing "1/4". | |
| ONE_THIRD | back to summary |
|---|---|
| public static final BigFraction ONE_THIRD A fraction representing "1/3". | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Serializable version identifier. | |
| THREE_FIFTHS | back to summary |
|---|---|
| public static final BigFraction THREE_FIFTHS A fraction representing "3/5". | |
| THREE_QUARTERS | back to summary |
|---|---|
| public static final BigFraction THREE_QUARTERS A fraction representing "3/4". | |
| TWO | back to summary |
|---|---|
| public static final BigFraction TWO A fraction representing "2 / 1". | |
| TWO_FIFTHS | back to summary |
|---|---|
| public static final BigFraction TWO_FIFTHS A fraction representing "2/5". | |
| TWO_QUARTERS | back to summary |
|---|---|
| public static final BigFraction TWO_QUARTERS A fraction representing "2/4". | |
| TWO_THIRDS | back to summary |
|---|---|
| public static final BigFraction TWO_THIRDS A fraction representing "2/3". | |
| ZERO | back to summary |
|---|---|
| public static final BigFraction ZERO A fraction representing "0". | |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final BigInteger num)
Create a
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(BigInteger num, BigInteger den) Create a
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final double value) throws MathIllegalArgumentException Create a fraction given the double value.
This constructor behaves differently from
Since this conversion is exact and since double numbers are sometimes
approximated, the fraction created may seem strange in some cases. For example,
calling
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final double value, final double epsilon, final int maxIterations) throws FractionConversionException Create a fraction given the double value and maximum error allowed. References:
| |
| BigFraction | back to summary |
|---|---|
| private BigFraction(final double value, final double epsilon, final int maxDenominator, int maxIterations) throws FractionConversionException Create a fraction given the double value and either the maximum error allowed or the maximum number of denominator digits. Note This constructor is called with EITHER - a valid epsilon value and the maxDenominator set to Integer.MAX_VALUE (that way the maxDenominator has no effect). OR - a valid maxDenominator value and the epsilon value set to zero (that way epsilon only has effect if there is an exact match before the maxDenominator value is reached). It has been done this way so that the same code can be (re)used for both scenarios. However this could be confusing to users if it were part of the public API and this constructor should therefore remain PRIVATE. See JIRA issue ticket MATH-181 for more details: https://issues.apache.org/jira/browse/MATH-181
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final double value, final int maxDenominator) throws FractionConversionException Create a fraction given the double value and maximum denominator. References:
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final int num)
Create a
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final int num, final int den)
Create a
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final long num)
Create a
| |
| BigFraction | back to summary |
|---|---|
| public BigFraction(final long num, final long den)
Create a
| |
| abs | back to summary |
|---|---|
| public BigFraction abs()
Returns the absolute value of this
| |
| add | back to summary |
|---|---|
| public BigFraction add(final BigInteger bg) throws NullArgumentException Implements org.
Adds the value of this fraction to the passed
| |
| add | back to summary |
|---|---|
| public BigFraction add(final int i) Implements org.
Adds the value of this fraction to the passed
| |
| add | back to summary |
|---|---|
| public BigFraction add(final long l) Implements org.
Adds the value of this fraction to the passed
| |
| add | back to summary |
|---|---|
| public BigFraction add(final BigFraction fraction) Implements org. Adds the value of this fraction to another, returning the result in reduced form.
| |
| bigDecimalValue | back to summary |
|---|---|
| public BigDecimal bigDecimalValue()
Gets the fraction as a
| |
| bigDecimalValue | back to summary |
|---|---|
| public BigDecimal bigDecimalValue(final int roundingMode)
Gets the fraction as a
| |
| bigDecimalValue | back to summary |
|---|---|
| public BigDecimal bigDecimalValue(final int scale, final int roundingMode)
Gets the fraction as a
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(final BigFraction object) Implements java. Compares this object to another based on size.
| |
| divide | back to summary |
|---|---|
| public BigFraction divide(final BigInteger bg) Implements org.
Divide the value of this fraction by the passed
| |
| divide | back to summary |
|---|---|
| public BigFraction divide(final int i) Implements org.
Divide the value of this fraction by the passed
| |
| divide | back to summary |
|---|---|
| public BigFraction divide(final long l) Implements org.
Divide the value of this fraction by the passed
| |
| divide | back to summary |
|---|---|
| public BigFraction divide(final BigFraction fraction) Implements org. Divide the value of this fraction by another, returning the result in reduced form.
| |
| doubleValue | back to summary |
|---|---|
| public double doubleValue() Implements abstract java.
Gets the fraction as a
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object other) Overrides java. Test for the equality of two fractions. If the lowest term numerator and denominators are the same for both fractions, the two fractions are considered to be equal.
| |
| floatValue | back to summary |
|---|---|
| public float floatValue() Implements abstract java.
Gets the fraction as a
| |
| getDenominator | back to summary |
|---|---|
| public BigInteger getDenominator()
Access the denominator as a
| |
| getDenominatorAsInt | back to summary |
|---|---|
| public int getDenominatorAsInt()
Access the denominator as a
| |
| getDenominatorAsLong | back to summary |
|---|---|
| public long getDenominatorAsLong()
Access the denominator as a
| |
| getField | back to summary |
|---|---|
| public BigFractionField getField() Implements org. Doc from org. Get the
| |
| getNumerator | back to summary |
|---|---|
| public BigInteger getNumerator()
Access the numerator as a
| |
| getNumeratorAsInt | back to summary |
|---|---|
| public int getNumeratorAsInt()
Access the numerator as a
| |
| getNumeratorAsLong | back to summary |
|---|---|
| public long getNumeratorAsLong()
Access the numerator as a
| |
| getReducedFraction | back to summary |
|---|---|
| public static BigFraction getReducedFraction(final int numerator, final int denominator)
Creates a Any negative signs are resolved to be on the numerator.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Gets a hashCode for the fraction.
| |
| intValue | back to summary |
|---|---|
| public int intValue() Implements abstract java.
Gets the fraction as an
| |
| longValue | back to summary |
|---|---|
| public long longValue() Implements abstract java.
Gets the fraction as a
| |
| multiply | back to summary |
|---|---|
| public BigFraction multiply(final BigInteger bg) Implements org.
Multiplies the value of this fraction by the passed
| |
| multiply | back to summary |
|---|---|
| public BigFraction multiply(final int i) Implements org.
Multiply the value of this fraction by the passed
| |
| multiply | back to summary |
|---|---|
| public BigFraction multiply(final long l) Implements org.
Multiply the value of this fraction by the passed
| |
| multiply | back to summary |
|---|---|
| public BigFraction multiply(final BigFraction fraction) Implements org. Multiplies the value of this fraction by another, returning the result in reduced form.
| |
| negate | back to summary |
|---|---|
| public BigFraction negate() Implements org. Return the additive inverse of this fraction, returning the result in reduced form.
| |
| percentageValue | back to summary |
|---|---|
| public double percentageValue()
Gets the fraction percentage as a
| |
| pow | back to summary |
|---|---|
| public BigFraction pow(final int exponent)
Returns a
| |
| pow | back to summary |
|---|---|
| public BigFraction pow(final long exponent)
Returns a
| |
| pow | back to summary |
|---|---|
| public BigFraction pow(final BigInteger exponent)
Returns a
| |
| pow | back to summary |
|---|---|
| public double pow(final double exponent)
Returns a
| |
| reciprocal | back to summary |
|---|---|
| public BigFraction reciprocal() Implements org. Return the multiplicative inverse of this fraction.
| |
| reduce | back to summary |
|---|---|
| public BigFraction reduce()
Reduce this
| |
| subtract | back to summary |
|---|---|
| public BigFraction subtract(final BigInteger bg) Implements org.
Subtracts the value of an
| |
| subtract | back to summary |
|---|---|
| public BigFraction subtract(final int i) Implements org.
Subtracts the value of an
| |
| subtract | back to summary |
|---|---|
| public BigFraction subtract(final long l) Implements org.
Subtracts the value of a
| |
| subtract | back to summary |
|---|---|
| public BigFraction subtract(final BigFraction fraction) Implements org. Subtracts the value of another fraction from the value of this one, returning the result in reduced form.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java.
Returns the
| |