You can beside the other Answers also round the number by multiplying the result times 10^n where n stands for the last significant decimalpoint you wanna achieve then round this(adding 0.5 for proper rounding like mathematicians do)by casting to an int and then divide it by 10^3 back again
maybe a method like this would do the trick:
Java:
public double rndMyNmb(double number,int decimalPoint);
{
number*=Math.pow(10,decimalPoint);
number=(int)(number+0.5);
return number/Math.pow(10,decimalPoint);
}
ofc you could write everything inside the method as one-liner:
return (double)((int)(number*Math.pow(10,decimalPoint)+0.5)/Math.pow(10,decimalPoint));