|
|
@ -73,10 +73,11 @@ public class MathHelper
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static BigInteger floor_double_BigInteger(double val) {
|
|
|
|
public static BigInteger floor_double_BigInteger(double val) {
|
|
|
|
return new BigInteger(String.format("%.0f", Math.floor(val)));
|
|
|
|
return new BigInteger(String.format("%.0f", Math.floor(normalize(val))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static BigInteger toBigInteger(double val) {
|
|
|
|
public static BigInteger toBigInteger(double val) {
|
|
|
|
|
|
|
|
val = normalize(val);
|
|
|
|
val = val < 0 ? Math.floor(val) + 1 : Math.floor(val);
|
|
|
|
val = val < 0 ? Math.floor(val) + 1 : Math.floor(val);
|
|
|
|
return new BigInteger(String.format("%.0f", val));
|
|
|
|
return new BigInteger(String.format("%.0f", val));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -84,6 +85,12 @@ public class MathHelper
|
|
|
|
public static BigDecimal toBigDecimal(BigInteger val) {
|
|
|
|
public static BigDecimal toBigDecimal(BigInteger val) {
|
|
|
|
return new BigDecimal(new java.math.BigInteger(val.toByteArray()));
|
|
|
|
return new BigDecimal(new java.math.BigInteger(val.toByteArray()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static double normalize(double val) {
|
|
|
|
|
|
|
|
if(Double.isInfinite(val)) val = Double.MAX_VALUE * Math.signum(val);
|
|
|
|
|
|
|
|
if(Double.isNaN(val)) val = 0;
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static float abs(float par0)
|
|
|
|
public static float abs(float par0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|