Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class BigFraction extends Number implements Serializable, Comparable<BigFraction>
| Modifier and Type | Class and Description |
|---|---|
static class |
BigFraction.DistributionMethod |
| Modifier and Type | Field and Description |
|---|---|
static BigFraction |
ONE |
static BigFraction |
ZERO |
| Constructor and Description |
|---|
BigFraction(BigInteger numerator,
BigInteger denominator,
boolean displayPercentage) |
BigFraction(long numerator,
long denominator,
boolean displayPercentage) |
BigFraction(String value) |
| Modifier and Type | Method and Description |
|---|---|
BigFraction |
abs()
Gets the absolute value, but is not reduced.
|
BigFraction |
add(BigFraction val)
Adds two fractions, returning the value in lowest terms.
|
int |
compareTo(BigFraction o) |
static BigDecimal[] |
distributeValue(BigDecimal total,
BigFraction.DistributionMethod distributionMethod,
BigFraction... fractions)
Evenly distributes the total value of BigDecimal by fractional amounts.
|
BigFraction |
divide(BigFraction val)
Divides two fractions, returning the value in lowest terms.
|
double |
doubleValue() |
boolean |
equals(Object o)
Two fractions are equal when they have both the same numerator, denominator, and displayPercentage.
|
float |
floatValue() |
BigDecimal |
getBigDecimal(int scale)
Gets this fraction as a BigDecimal using
RoundingMode.UNNECESSARY |
BigDecimal |
getBigDecimal(int scale,
RoundingMode roundingMode)
Gets this fraction as a BigDecimal using the provided rounding mode.
|
BigInteger |
getBigInteger()
Gets this fraction as a BigInteger using
RoundingMode.UNNECESSARY |
BigInteger |
getBigInteger(RoundingMode roundingMode)
Gets this fraction as a BigInteger using the provided rounding mode.
|
BigInteger |
getDenominator() |
BigInteger |
getNumerator() |
int |
hashCode() |
int |
intValue() |
boolean |
isDisplayPercentage() |
long |
longValue() |
BigFraction |
max(BigFraction val)
Gets the higher of the two fractions.
|
BigFraction |
min(BigFraction val)
Gets the lower of the two fractions.
|
BigFraction |
multiply(BigFraction val)
Multiplies two fractions, returning the value in lowest terms.
|
BigFraction |
negate()
Negates the value, but is not reduced.
|
BigFraction |
pow(int exponent)
Raises this fraction to the provided exponent, returning the value in lowest terms.
|
BigFraction |
reduce()
Reduces this fraction to its lowest terms.
|
int |
signum()
Returns the signum function of this
BigFraction. |
BigFraction |
subtract(BigFraction val)
Subtracts two fractions, returning the value in lowest terms.
|
String |
toString() |
static BigFraction |
valueOf(BigDecimal value,
boolean displayPercentage)
Gets the big decimal as a fraction, reduced.
|
static BigFraction |
valueOf(BigInteger numerator,
BigInteger denominator,
boolean displayPercentage) |
static BigFraction |
valueOf(BigInteger value,
boolean displayPercentage) |
static BigFraction |
valueOf(long numerator,
long denominator,
boolean displayPercentage) |
byteValue, shortValuepublic static final BigFraction ZERO
public static final BigFraction ONE
public BigFraction(String value) throws NumberFormatException
NumberFormatExceptionpublic BigFraction(long numerator,
long denominator,
boolean displayPercentage)
throws NumberFormatException
NumberFormatExceptionpublic BigFraction(BigInteger numerator, BigInteger denominator, boolean displayPercentage) throws NumberFormatException
NumberFormatExceptionpublic static BigFraction valueOf(long numerator, long denominator, boolean displayPercentage) throws NumberFormatException
NumberFormatExceptionpublic static BigFraction valueOf(BigInteger value, boolean displayPercentage) throws NumberFormatException
NumberFormatExceptionpublic static BigFraction valueOf(BigDecimal value, boolean displayPercentage) throws NumberFormatException
NumberFormatExceptionpublic static BigFraction valueOf(BigInteger numerator, BigInteger denominator, boolean displayPercentage) throws NumberFormatException
NumberFormatExceptionpublic static BigDecimal[] distributeValue(BigDecimal total, BigFraction.DistributionMethod distributionMethod, BigFraction... fractions)
total.total.total.total.total - The total value to be distributed within the resultsfractions - The fractional amount of each result, the sum must be equal to one. The array elements are unmodified.public BigInteger getNumerator()
public BigInteger getDenominator()
public boolean isDisplayPercentage()
public float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic BigInteger getBigInteger() throws ArithmeticException
RoundingMode.UNNECESSARYArithmeticExceptionpublic BigInteger getBigInteger(RoundingMode roundingMode) throws ArithmeticException
ArithmeticExceptionpublic BigDecimal getBigDecimal(int scale) throws ArithmeticException
RoundingMode.UNNECESSARYArithmeticExceptionpublic BigDecimal getBigDecimal(int scale, RoundingMode roundingMode) throws ArithmeticException
ArithmeticExceptionpublic boolean equals(Object o)
compareTo.equals in class ObjectcompareTo(BigFraction)public int compareTo(BigFraction o)
compareTo in interface Comparable<BigFraction>public BigFraction reduce()
public BigFraction add(BigFraction val)
public BigFraction subtract(BigFraction val)
public BigFraction multiply(BigFraction val)
public BigFraction divide(BigFraction val)
public BigFraction negate()
public BigFraction abs()
public BigFraction max(BigFraction val)
this.public BigFraction min(BigFraction val)
this.public BigFraction pow(int exponent)
public int signum()
BigFraction.BigFraction
is negative, zero, or positive.Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.