When I run the code
System.out.println(12%5)
It always, without fail, prints out 2. But, if it try this:
System.out.println(2%0.1)
It prints out 0.0999999999999999. Im trying to use the % operator to round a number down to a given interval, but if the interval is a decimal, it always glitches like this. What alternatives exist? Thanks.
EDIT: The code i'm using to round to the nearest interval is this:
value -= value%0.1;
If value were to equal 0.567, value%0.1 would be 0.067, and 0.567-0.067 = 0.5.