Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert four bytes into integers? And vice versa? Java language (a computer language, especially for creating websites)
How to convert four bytes into integers? And vice versa? Java language (a computer language, especially for creating websites)
About the mistake, right here.

int a = bytes[0]& lt; & lt24+ bytes [1] < & lt 16+ bytes [2] < & lt8+ bytes [3];

+and

So the above formula becomes bytes [0] < <; 46 & lt& lt38 & lt& lt30

Obviously, after so many left shifts,

A must be equal to 0.

Just put brackets around each item in the formula.

int a =(bytes[0]& lt; & lt24)+(bytes[ 1]& lt; & lt 16)+(bytes[2]& lt; & lt8)+ bytes [3];

————————

Numbers are stored in the computer in binary form.

For example, 22 is 000 10 1 10.