Hi,
In Java, bytes are signed. The possible values range from -128 to +127.
> if ( var == 0xC0)
You are comparing a signed byte to an integer, Java simply convert var
to an integer and compares it to the integer 0xC0 (192 in decimal.)
You can verify this easily by decompiling the following source code:
byte b = (byte) 0xC0;
if (b == 0xC0) {
System.out.println(b);
}
You obtain:
0: bipush -64
2: istore_1
3: iload_1
4: sipush 192
7: if_icmpne 17
10: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
13: iload_1
14: invokevirtual #3; //Method java/io/PrintStream.println:(I)V
17: return
As you can see, the decimal value -64 is stored in the byte but it's
compared against the integer value 192.
--
Romain Guy
www.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---