Guys i want to understand , how the widening or narrow implicit casting is internally implemented in java.I know that it involves bit fiddling.
For example:
//implicit
int i =2400;
long a = (long)i;
//Explicit
float d = (float) 2.23423;
Updates:
I wrote this post after looking at the question
posted here Bitshifting to read/write data
.Peter Lawrey gave the following answer.
public long create(int one, int two){
return ((long) one << 32) | (two & 0xFFFFFFFFL);
}
To re-iterate same,widening conversion like above happens at the machine level more or less with smiliar same logic mentioned above by peter.
kindly let me know your valuable comments.
Java uses the IEEE 754 standard machine code instructions supported by your CPU. As such Java does not implement this functionality using something you can break down further.
For conversion from double to float.
For float to double the process is similar except fields are extended.
However this is all done in the floating point processor unit and Java plays no part in how it happens.