This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integer to Byte

 
Balaji Bang
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

how the convertion from integer to byte happens?
byte y=(byte)230;

y value is -26.how the result will be -26
anyone please help me.....
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well Banu the value 230 is out of the range of byte which is from -128 to 127. So the value 230 will be truncated. This truncation happens at the binary level. Just read a tutorial about Number Systems to understand this concept...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic