poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Ackley" <sack...@cfl.rr.com>
Subject Re: HWPF: java doubts
Date Thu, 03 Jul 2003 10:09:24 GMT
> Thats cool!!
> Then why we need getUnsignedByte() itself??
> eg:  to read a byte read 0xff , get its unsigned value by typcasting to
> int  i,e 0x000000ff;
> & to write it back just write the byte  0xff.

The byte 0xff is equal to -1 so when you cast it to an int you end up with
an int that is equal to -1 (0xffffffff). We want an int that is equal to
255. When you cast from a smaller precision number to a larger precision
number (byte->int) the JVM will always preserve the sign.

View raw message