I want to round a double value to the next even integer number. e.g.:
I've tried Math.rint(), but it gives me 489 instead of 490. 
Simply:
public static long roundEven(double d) {
    return Math.round(d / 2) * 2;
}
Gives:
System.out.println(roundEven(2.999));  // 2 
System.out.println(roundEven(3.001));  // 4 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With