Package org.apache.poi.ss.format
Class SimpleFraction
java.lang.Object
org.apache.poi.ss.format.SimpleFraction
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleFraction(int numerator, int denominator) Create a fraction given a numerator and denominator. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleFractionbuildFractionExactDenominator(double val, int exactDenom) Create a fraction given a double value and a denominator.static SimpleFractionbuildFractionMaxDenominator(double value, int maxDenominator) Create a fraction given the double value and either the maximum error allowed or the maximum number of denominator digits.intAccess the denominator.intAccess the numerator.
-
Constructor Details
-
SimpleFraction
public SimpleFraction(int numerator, int denominator) Create a fraction given a numerator and denominator.- Parameters:
numerator-denominator- maxDenominator The maximum allowed value for denominator
-
-
Method Details
-
buildFractionExactDenominator
Create a fraction given a double value and a denominator.- Parameters:
val- double value of fractionexactDenom- the exact denominator- Returns:
- a SimpleFraction with the given values set.
-
buildFractionMaxDenominator
Create a fraction given the double value and either the maximum error allowed or the maximum number of denominator digits.- Parameters:
value- the double value to convert to a fraction.maxDenominator- maximum denominator value allowed.- Throws:
RuntimeException- if the continued fraction failed to converge.IllegalArgumentException- if value > Integer.MAX_VALUE
-
getDenominator
public int getDenominator()Access the denominator.- Returns:
- the denominator.
-
getNumerator
public int getNumerator()Access the numerator.- Returns:
- the numerator.
-