vendredi 28 novembre 2014

Type Casting in Java


Could anyone explain why short(100000) is -31072 as said in p.48 of java-notes.The article says that "the value -31072 is obtained by taking the the 4 byte int 100000 and throwing away two of these bytes to obtain a short".


The code in the article related to the question is:



int A;
short B;
A = 17;
B = (short)A;




Aucun commentaire:

Enregistrer un commentaire