Page 150 of Sun Cert. by Sierra and Bates states that we get the cast from int to short for free. short s2 = 0x7fff; works but not this one: short s1 = 0x8000;
Hi Mo Bustany, I think the highest order bit is used as sign bit. So if the number is greater than 0x7fff and assigned to short if give give a loss of precision compilation error. Regards, Padma
Don't forget that this literal 0x8000 is type int. Since it is type int, it has 32 bits. It looks like this, 0000 0000 0000 0000 1000 0000 0000 0000 Maybe this makes it more obvious that the value is decimal 32768.
Dinner will be steamed monkey heads with a side of tiny ads.