I need to read a byte array of 16 bits as unsigned short number, and Java doesn’t support unsigned short type.
So how can i do it?? Please help!!
I need to read a byte array of 16 bits as unsigned short number,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you have it available as binary data from a non-Java source that you must read and work with the values in Java:
Read it as a (signed)
short, and then convert it tointas follows:You cannot represent all values of an unsigned short in a short, but in an int, you can.