What about
double rounded = Math.ceil(number * 2) / 2;
Since Math.ceil()double already returns, there is no need to share on 2.0dhere. This will work fine if you are in a range of integers that can be expressed as doubles without loss of precision, but be careful if you fall out of this range.
source
share