Class SimpleFraction
java.lang.Object
org.xlsx4j.org.apache.poi.ss.format.SimpleFraction
public class SimpleFraction
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description SimpleFraction(int numerator, int denominator)Create a fraction given a numerator and denominator. -
Method Summary
Modifier and Type Method Description static 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.intgetDenominator()Access the denominator.intgetNumerator()Access the numerator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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:
java.lang.RuntimeException- if the continued fraction failed to converge.java.lang.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.
-