| Author |
Mock Question
|
tanu dua
Ranch Hand
Joined: Apr 05, 2004
Posts: 145
|
|
Hi all ! Can anyone plz explain the output of the following program : Output : INFINITY -1 Problem: How infinity is converted to -1 while casting. Thanx
|
 |
Tybon Wu
Ranch Hand
Joined: Jun 18, 2002
Posts: 84
|
|
When casting double to byte, the value of the double is converted to an int first, and then from int to byte. So, when you convert infinity to int, you get 0x7fffffff. When you convert 0x7fffffff to byte, you get 0xff, which is -1.
|
SCJP2
|
 |
tanu dua
Ranch Hand
Joined: Apr 05, 2004
Posts: 145
|
|
Thanx mate !! You have cleared my doubts ...
|
 |
 |
|
|
subject: Mock Question
|
|
|