This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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
 
Consider Paul's rocket mass heater.
 
subject: -97 is the total length of each record ???
 
Similar Threads
Out of Bounds Exception returns and the eradication thereof.
totaling array rows and columns
URLyBird data file and DBMain interface
need help with calculation in my spreadsheet array
HashMap and Vector