I can't understand why this
float f = Integer.MAX_VALUE; System.out.println(Integer.MAX_VALUE); System.out.println((int)f); produces the same lines,
As well as why this does
Float f2 = (float) Integer.MAX_VALUE; System.out.println(Integer.MAX_VALUE); System.out.println(f2.intValue()); I mean, mantissa length for floating point number is 2^23-1. How does it manage to keep max_value of integer, which is 2^31 - 1?
floatis you can avoid it.doublegives you half a trillion times the accuracy. Some suggest you should use BigDecimal (not my preference however)