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

Overflow?

 
Dan Temple
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been using the JQ+ tester which has been worth every penny. However I have come across a question which seems wrong. But since they have been always right before, its probably me that's wrong. here is the question:
If write(0xAABBCCDD) is called on an instance of FileOutputStream, what will be written to the destination of the stream?
They say the answer is -
The byte 0xDD
But this seems wrong: Here is my reasoning, A Byte can only have a max value of 127 and DD is 221 in hex. In binary this is 11011101. Only the low order bits would be retained for a byte which is 1011101 which is 93, or 5D in hex. What am I missing?
Dan
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The byte 0xDD in decimal is -35 (a valid value).
Geoffrey
 
Dan Temple
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah yes ... I forgot that high order bit. Thanks for the reply
Dan
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic