prevent non-terminating BigDecimal division

This commit is contained in:
woodser 2023-03-09 12:08:30 -05:00
parent 47f3d98597
commit 60341002fd
6 changed files with 12 additions and 13 deletions

View file

@ -72,7 +72,6 @@ import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.collections.transformation.SortedList;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
@ -633,7 +632,7 @@ abstract class OfferBookViewModel extends ActivatableViewModel {
}
public String formatDepositString(BigInteger deposit, long amount) {
var percentage = FormattingUtils.formatToRoundedPercentWithSymbol(BigDecimal.valueOf(deposit.longValueExact()).divide(BigDecimal.valueOf(amount)).doubleValue());
var percentage = FormattingUtils.formatToRoundedPercentWithSymbol(HavenoUtils.divide(deposit, BigInteger.valueOf(amount)));
return HavenoUtils.formatXmr(deposit) + " (" + percentage + ")";
}