Understanding Java unsigned numbers

后端 未结 3 1010
礼貌的吻别
礼貌的吻别 2021-01-03 00:59

I want to understand how to convert signed number into unsigned.

lets say I have this:

byte number = 127; // \'1111111\'

In order t

3条回答
  •  误落风尘
    2021-01-03 02:01

    If you just move from a negative byte to int the int will be negative too. Sou you take the negative int (or short in your example) and set the highest 3 byte (int) to 0x00.

提交回复
热议问题