posted 13 years ago

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.

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

posted 13 years ago

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 ]

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 ]

It is sorta covered in the JavaRanch Style Guide. |