mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-11-30 08:26:41 -05:00
use BigInteger for average chart calculations
This commit is contained in:
parent
3546d3d931
commit
33c9628df3
2 changed files with 31 additions and 16 deletions
|
|
@ -22,6 +22,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
|
@ -85,6 +86,11 @@ public class MathUtils {
|
|||
return ((double) value) * factor;
|
||||
}
|
||||
|
||||
public static BigInteger scaleUpByPowerOf10(BigInteger value, int exponent) {
|
||||
BigInteger factor = BigInteger.TEN.pow(exponent);
|
||||
return value.multiply(factor);
|
||||
}
|
||||
|
||||
public static double scaleDownByPowerOf10(double value, int exponent) {
|
||||
double factor = Math.pow(10, exponent);
|
||||
return value / factor;
|
||||
|
|
@ -95,6 +101,11 @@ public class MathUtils {
|
|||
return ((double) value) / factor;
|
||||
}
|
||||
|
||||
public static BigInteger scaleDownByPowerOf10(BigInteger value, int exponent) {
|
||||
BigInteger factor = BigInteger.TEN.pow(exponent);
|
||||
return value.divide(factor);
|
||||
}
|
||||
|
||||
public static double exactMultiply(double value1, double value2) {
|
||||
return BigDecimal.valueOf(value1).multiply(BigDecimal.valueOf(value2)).doubleValue();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue