This week's book giveaway is in the Cloud/Virtualization forum.We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

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

Ranch Hand
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.

Ranch Hand
Posts: 63
You need to read this value as an int. Use the readInt() method.

Matt
[ October 17, 2004: Message edited by: Matt Sheehan. ]

Ranch Hand
Posts: 1392
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
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

 It is sorta covered in the JavaRanch Style Guide.