aspose file tools*
The moose likes Java in General and the fly likes Overflow? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Overflow?" Watch "Overflow?" New topic
Author

Overflow?

Dan Temple
Ranch Hand

Joined: Jul 10, 2001
Posts: 93
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

Joined: Aug 17, 2001
Posts: 171
    
    1
The byte 0xDD in decimal is -35 (a valid value).
Geoffrey


Sun Certified Programmer for the Java 2 Platform
Dan Temple
Ranch Hand

Joined: Jul 10, 2001
Posts: 93
Ah yes ... I forgot that high order bit. Thanks for the reply
Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overflow?
 
Similar Threads
serial number form x509 certificate
a little BYTE of problem....
From Byte[] to Ascii text String
Casting a byte to an int....
Trouble Converting from Int Array to Byte Array