|
|
|
@ -73,10 +73,11 @@ public class MathHelper
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
val = normalize(val);
|
|
|
|
|
val = val < 0 ? Math.floor(val) + 1 : Math.floor(val);
|
|
|
|
|
return new BigInteger(String.format("%.0f", val));
|
|
|
|
|
}
|
|
|
|
@ -85,6 +86,12 @@ public class MathHelper
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
return par0 >= 0.0F ? par0 : -par0;
|
|
|
|
|