Reading a two's complement number from a InputStream
First, I am new to this forum, so sorry if I have posted this thread in a wrong place.
Now to my problem.
I have an application that is receiving data from an accelerometer. As we know, accelerometer data can be positive or negative, depending on which way we are moving along a given axis. So, my problem is this:
On the accelerometer, negative data is sent using two's complement binary notation, but when I receive it in my application, using int data = InputStream.read(), this number is stored as a normal int. So instead of getting values between -128 and 127 I get values between 0 and 255.
So what I want is to simply read from the InputStream and get a 8 bit binary value, instead of an int. Can anyone help me with my problem?