Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The problem of converting java bytes into int
The problem of converting java bytes into int
It's simple ... this example reads in a byte stream,

There is no concept of storing a specific type or length,

The compiler doesn't know that the last bit input at that time was the sign bit.

I don't even know what11111stands for.

So the conversion will only be carried out according to what it thinks is most likely.

Byte types have specific types and storage lengths.

Because there are no unsigned types in JAVA,

If you assign a value like this, JAVA will automatically ensure that the result will not change.

Otherwise, you think that every time you assign a value from the low position to the high position, you will get a different result from the high position.

It's terrible. ...