How do I convert a byte to a long in Java? -


I'm reading 8 bytes of data from the hardware device, I need to convert them to a numeric value, I think I I want to change them for a long time as it should have 8 bytes. I am not very familiar with operating Java and low level data types. I think there are two problems (in addition to the fact there is almost no document of hardware in it), the bytes are expected to be unsigned, so I can not convert a straightforward integer


Ended with (some taken from source code, maybe I should read one week earlier):

Public stable last long (byte [] bytere, int offset, int lane ) {Long val = 0; Lane = monastery.man (lane, 8); For (inti = (lane -1); i> = 0; i--) {val & lt; & Lt; = 8; Val == (Bytere [Offset + I] and 0x00FF); } Return valve; }

For endnines, test with some numbers that you know, and Then you will be using the transfer to move a byte for a long time.

You can have this a starting point.

The difficulty is that depending on the funeral you will change it, but you will make changes after 24, 16, 8, in the end, 32 bits are going, but you are going long , Then just do extra transfer.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -