Results 1 to 2 of 2
- 09-20-2010, 09:41 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 1
- Rep Power
- 0
Reading a two's complement number from a InputStream
Hello,
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?
Best regards,
Tor-Erik
- 09-20-2010, 02:21 PM #2
Similar Threads
-
Reading inputstream on socket
By javanetworknew in forum NetworkingReplies: 1Last Post: 04-27-2010, 11:01 AM -
Reading or changing sequenc number in TCP packets
By islamfunny in forum NetworkingReplies: 4Last Post: 09-23-2008, 01:44 PM -
Reading form inputStream and storing in ByteArray
By Java Tip in forum Java TipReplies: 0Last Post: 11-27-2007, 10:23 AM -
Reading bytes from InputStream
By Java Tip in forum Java TipReplies: 0Last Post: 11-25-2007, 07:51 PM -
Un expected behaviour when reading from inputstream
By adoorsarath in forum Advanced JavaReplies: 3Last Post: 08-10-2007, 05:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks