Results 1 to 2 of 2
- 09-20-2010, 09:41 AM #1Member
- Join Date
- Sep 2010
- Rep Power
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?
- 09-20-2010, 02:21 PM #2
- By javanetworknew in forum NetworkingReplies: 1Last Post: 04-27-2010, 11:01 AM
- By islamfunny in forum NetworkingReplies: 4Last Post: 09-23-2008, 01:44 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 11-27-2007, 11:23 AM
- By Java Tip in forum Java TipReplies: 0Last Post: 11-25-2007, 08:51 PM
- By adoorsarath in forum Advanced JavaReplies: 3Last Post: 08-10-2007, 05:02 PM