• Post Reply Bookmark Topic Watch Topic
  • New Topic

Overflow Question  RSS feed

 
Ivan Turner
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me why the data type of byte gives a valid arithmetic result whereas int does not. I understand what happened to the int due to overflow value but I don't understand why byte behaved differently.

Thanks in advance.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most operators produce int results (unless there is a long as one of the operands, in which case the operation produces a long results). So the type of b*2 isn't a byte, even though b is a byte, the type of the operation is int and int has no trouble holding 256 values.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For better understanding.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!