Hi,
Please consider the following piece of code
public class myclass
{
public static void main(
String args[])
{
byte a = -64;
byte b = 192;
System.out.println("the result is " + a*b);
}
}
My question is as follows:
Both 'a' and 'b' are represented internally as 11000000. When the expression a*b is evaluated both 'a' and 'b' are promoted to 'int' type. How does
java know that 'a' should be padded with '1s' and 'b' with '0s' ie how does java correctly represent 'a' and 'b' after promotion as
a = 11111111 11111111 11111111 11000000 -64
b = 00000000 00000000 00000000 11000000 +192
to get the correct result of the expression 'a*b'. Is there a tag or sign bit, other than the ambiguous (at least in this case) '1' in the MSB position ofcourse, somewhere that tells Java that 'a' is negative and 'b' is positive although both are represented internally using the same bit
pattern?
------------------
Bos Indicus