I am new to Java, and wondering how does double to int cast work ? I understand that it\'s simple for long to int by taking the low 32 bits, but what about double (64 bits)
Java truncates its value if you use (int) cast, as you may notice:
double d = 2.4d; int i = (int) d; System.out.println(i); d = 2.6; i = (int) d; System.out.println(i);
Output:
2 2
Unless you use Math.round, Math.ceil, Math.floor...