Package org.apache.poi.ss.format
Class SimpleFraction
- java.lang.Object
-
- org.apache.poi.ss.format.SimpleFraction
-
public class SimpleFraction extends Object
-
-
Constructor Summary
Constructors Constructor Description SimpleFraction(int numerator, int denominator)
Create a fraction given a numerator and denominator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleFraction
buildFractionExactDenominator(double val, int exactDenom)
Create a fraction given a double value and a denominator.static SimpleFraction
buildFractionMaxDenominator(double value, int maxDenominator)
Create a fraction given the double value and either the maximum error allowed or the maximum number of denominator digits.int
getDenominator()
Access the denominator.int
getNumerator()
Access the numerator.
-
-
-
Method Detail
-
buildFractionExactDenominator
public static SimpleFraction buildFractionExactDenominator(double val, int exactDenom)
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
public static SimpleFraction buildFractionMaxDenominator(double value, int maxDenominator)
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:
IllegalStateException
- 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.
-
-