• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Overflow?

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah yes ... I forgot that high order bit. Thanks for the reply
Dan
 
Oh the stink of it! Smell my tiny ad!
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic