long a = (long)Math.pow(2, 32);
long a = (int)(long)Math.pow(2, 32);
long a = (int)Math.pow(2, 32);
The first expression is obvious. a is printed as is.
The second expression is a bit confusing. Great importance
10000000000000000000000000000000000 // 1, followed by 32 ZEROs, 33 bits in all
When it is forced into an int, how is it done as ZERO? Shouldn't he take the most important 1s as a sign bit and assume that the number is -2147483648? [REMOVAL OF THE CASE]
Also, when the double returned from Math.pow (4.294967296E9) is directly converted to int, why is it 2147483647?
I read the casting type and data types from the book, but the text does not explain much. I'm confused. Please explain why the second and third expressions give these results.
user529141