• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Casting

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following line code of code makes no sense to me.
byte b= (byte)(long)(short)16.2;
pl share your comments with me..

-Sanjana
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic