From: Panayotis K. <pan...@pa...> - 2011-04-05 22:30:38
|
On Apr 5, 2011, at 8:49 PM, Arno Puder wrote: > > things are a little trickier. According to section 2.4.1 of the Java > Specs: "The integral types are byte, short, int, and long, whose values > are 8-bit, 16-bit, 32-bit, and 64-bit signed two's-complement integers, > respectively, and char, whose values are 16-bit unsigned integers > representing Unicode characters" > > Then in Section 3.11.1 of the Java spec it says: "Note that most > instructions in Table 3.2 do not have forms for the integral types byte, > char, and short. None have forms for the boolean type. Compilers encode > loads of literal values of types byte and short using Java virtual > machine instructions that sign-extend those values to values of type int > at compile time or run time. Loads of literal values of types boolean > and char are encoded using instructions that zero-extend the literal to > a value of type int at compile time or run time." > > So, you are correct that a byte is a signed 8-bit value, however it > needs to be properly sign extended. In the C backend I already use > typedef's consistently, so it should be easy to fix. The Objective-C > backend is not as cleanly implemented. > > Arno > So, the problem remains, should "byte" be a signed or unsigned char under ObjC backend, and especially in the Byte methods? My understanding is that it is sometimes a signed integer, but in any case, it is *not* an unsigned char. |