Hi, I have a byte[] and I'm trying to get out 1-2 bytes depending on whether it's 8bit or 16bit and to convert this to a short value. I'm not really sure how to do this as obviously I can't just add the bytes together, and I need to make sure that I know whether it is positive/negative (and little/big endian).
Can anybody explain how to do this?
edit: I am presuming that you can get out the first byte and shift it left by 8, and then add it to the other byte. But then how do I know whether the two bytes are positive or negative.
This surely must be a rather standard problem, so I wonder if there is any sample code anywhere that I can look at?
If LibreOffice wants to be taken seriously, they need to hire some UX designers. The UI is horrible, inconsistent and looks like what it is - a clone of Microsoft Office 2000. Look at what MuseScore has achieved with version 4 or the upcoming version of Audacity. MuseScore has now surpassed many commercial offerings in terms of UX.
Just look at the screenshot in this article. A Win9x style column header slapped on a Mac UI. Button sizing and text is all over the place. It is clear that absolutely no care was taken with the UI.
According to this there is a Beta build that you could try if you wanted: https://kubuntu.org/news/plasm...eta1-available-for-testing/
But like they say, since it's in Beta you might want to wait for their next official release which I think is scheduled for October.
Question
lhnz
Hi, I have a byte[] and I'm trying to get out 1-2 bytes depending on whether it's 8bit or 16bit and to convert this to a short value. I'm not really sure how to do this as obviously I can't just add the bytes together, and I need to make sure that I know whether it is positive/negative (and little/big endian).
Can anybody explain how to do this?
edit: I am presuming that you can get out the first byte and shift it left by 8, and then add it to the other byte. But then how do I know whether the two bytes are positive or negative.
This surely must be a rather standard problem, so I wonder if there is any sample code anywhere that I can look at?
Edited by lhnzLink to comment
https://www.neowin.net/forum/topic/709892-java-convert-1-2-bytes-into-a-short/Share on other sites
7 answers to this question
Recommended Posts