Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overflow of byte

 
Robert Ziel
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
can someone explain to me when a byte flows over
it turns negative .. ???
thanks,
Robert
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,
A byte is an 8 bit integer data type. The possible range of the value of a byte is -128 to 127. Let's consider adding one to the bit representation of the maximum value of 127:

Now, mosey on over to The JavaRanch Campfire and learn all about Cat and Mouse Games with Bits!
Good Luck.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dirk, it looks like your binary addition could use a little help.

Just wanted to clear that up.
Corey
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, it was early in the morning. You should have seen the first draft - it was worse.
Thanks Corey.
 
Robert Ziel
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys,
this clears it up...
Robert
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic