double temp = 64.1;
System.out.println("Result = " + (temp*1000));
The result would be:
Result = 64099.99999999999
But the actual result should be 64100
In case of Double data type
double a = ((temp * 1000) % (0.5 * 1000));
a=7.275957614183426E-12;
In case of casting it to float
((((float) temp) * 1000) % (0.5 * 1000));
a=0.0;
Why this behaviour?