Fixed rounding

This commit is contained in:
Fuzzlemann 2017-07-25 19:25:01 +02:00
parent 1d0939d916
commit a7e65bdcd9

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.utilities.analysis;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.OptionalDouble;
import java.util.OptionalInt;
@ -169,6 +170,8 @@ public class MathUtils {
return biggest.isPresent() ? biggest.getAsLong() : 1;
}
private static final DecimalFormat df = new DecimalFormat("#.##");
/**
* Rounds the double to a double with two digits at the end.
* Output: #.##
@ -177,6 +180,6 @@ public class MathUtils {
* @return The rounded number
*/
public static double round(double number) {
return Math.round(number * 100.0) / 100.0;
return Double.valueOf(df.format(number));
}
}