の不可欠な部分をBigFraction
として取得する簡単な方法は何BigInteger
ですか?
基本的に、intValue
andlongValue
メソッドが返すのと同じ結果が必要ですが、任意の精度が必要です。
また、丸めを避けたいので、aを介した間接変換BigDecimal
は適切ではありません。
の不可欠な部分をBigFraction
として取得する簡単な方法は何BigInteger
ですか?
基本的に、intValue
andlongValue
メソッドが返すのと同じ結果が必要ですが、任意の精度が必要です。
また、丸めを避けたいので、aを介した間接変換BigDecimal
は適切ではありません。
myBigFraction.getNumerator().divide( myBigFraction.getDemoninator() );
?
あなたはこのようなことを試すことができます
BigFraction fraction = ...
BigInteger num = fraction.getNumerator();
BigInteger den = fraction.getDenominator();
BigInteger[] divideAndReminder = num.divideAndRemainder(den);
そしてついに
BigInteger integralPart = divideAndReminder[0];
これでうまくいくはずです。
bigInteger = bigFraction.genNumerator().divide(bigFraction.getDenominator());