This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes -97 is the total length of each record ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "-97 is the total length of each record ???" Watch "-97 is the total length of each record ???" New topic
Author

-97 is the total length of each record ???

M Jay
Ranch Hand

Joined: Sep 21, 2004
Posts: 66
Hello everyone,

In my schema description, I have the second 4 bytes representing the overall total length of each records, in my data file, this is:

000-97

what does this mean?? surely it can't be -97

when I print out each byte seperately I get

0 0 0 -97

any help will be appreciated.


SCJP J2SE 1.4<br />SCBCD J2EE 1.3
Matt Sheehan.
Ranch Hand

Joined: Oct 08, 2004
Posts: 63
You need to read this value as an int. Use the readInt() method.

Matt
[ October 17, 2004: Message edited by: Matt Sheehan. ]
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
00000000 00000000 00000000 10011111

In two's complement arithmetic of 8-bit numbers, the binary numbers 00000000 to 01111111 represent the decimal numbers 0 to 127 and the binary numbers 10000000 to 11111111 represent the decimal numbers -128 to -1. In particular 10011111 represents -97. (128 + 31 - 2^8)

In two's complement arithmetic of 32-bit numbers, the binary numbers
00000000 00000000 00000000 0000000 to 00000000 00000000 00000000 11111111
represent the decimal numbers 0 to 255. In particular 00000000 00000000 00000000 10011111 represents 159. (128 + 31)
[ October 17, 2004: Message edited by: Marlene Miller ]
M Jay
Ranch Hand

Joined: Sep 21, 2004
Posts: 66
Hey Marlene,

Thank you so much, now it makes more sense
Is there a way for me to read these values in and print them out in their simple form... i.e. 159 ??? readInt() doesn't seem to do it

Thanks
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: -97 is the total length of each record ???
 
It's not a secret anymore!