In the spirit of using existing, tested and stable libraries of code, I started using the Apache-Commons-Math library and its BigFraction class to perform some rational calculations for an Android app I'm writing called RationalCalc.
It works great for every task that I have thrown at it, except for one nagging problem. When dividing c...
What is an easy way to get the integral part of a BigFraction as a BigInteger?
Basically I want the same result that the intValue and longValue methods return but with arbitrary precision.
I also want to avoid rounding so indirect conversion via a BigDecimal is not suitable.
...
public class BigFraction
{
private BigInteger num;
private BigInteger denom;
//public static final BigFraction ZERO;
/**
*
* Creates a BigFraction with numeriator BigInteger.ZERO and denominator BigInteger.ONE
*
*/
public BigFraction()
{
//should be 0/1
num = BigInteger.ZERO;
denom = BigInteger.ONE;
}
public BigF...