wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Casting" Watch "Casting" New topic


sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
The following line code of code makes no sense to me.
byte b= (byte)(long)(short)16.2;
pl share your comments with me..

Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Hi sanjana,
The byte, short, long datatypes can't hold fraction values. What happens in your code, is that 16.2 is treated as double then it is casted to short (16), long(16), byte(16) respectively, hence truncating its value to 16.
[ December 08, 2003: Message edited by: Vicken Karaoghlanian ]

- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
I agree. Here's the link: http://aspose.com/file-tools
subject: Casting
jQuery in Action, 3rd edition