> float f=40.3f;
> System.out.println(f%4);
>
>
> The answer for above must be 0.3 but java gives
> 0.29999924
> WHY?
> (This answer is ok for small calculations but it may
> give wrong answers for large calculations)
Use BigDecimal with MathContext or roll your own Fraction class- this way any repeating decimal is represented exactly.
Message was edited by:
snic.snac