How to set number of decimals?
Hello!I thought that I know this but I did not, very annoying!
I got code like this:
float x
public void updateX(int x)
{
this.x = this.x + (x/100f);
System.out.println((this.x + (x/100f)));
}
I only want 2 decimal for x but I get like 8!!
For eg if I call updateX like below when x is 0.04:
updateX(1);
I get this value at x: 0.049999997 but I would like 0.05!
So if any one have the solution please let me know cause I know there is some way to set the number of digits in the decimalpart.
Best regards
Fredrik
