saunwin Active Member Licensed User Longtime User May 17, 2017 #1 Good evening Guru's, I have a problem, hope you can help. I'm receiving bytes (BTooth) nicely, BUT I'm doing some intensive bit manipulation. Bytes are -128 to +128 and I need 0-255 I thought byteconverter library did it, but alas a cast error is cropping up here. Please steer me straight someone - TIA. Code: Copy Dim I As Int = bc.hexFromBytes(Buffer(0))
Good evening Guru's, I have a problem, hope you can help. I'm receiving bytes (BTooth) nicely, BUT I'm doing some intensive bit manipulation. Bytes are -128 to +128 and I need 0-255 I thought byteconverter library did it, but alas a cast error is cropping up here. Please steer me straight someone - TIA. Code: Copy Dim I As Int = bc.hexFromBytes(Buffer(0))
eps Expert Licensed User Longtime User May 17, 2017 #2 IntsFromBytes instead? You might need to transpose or... Maybe check this? https://www.b4x.com/android/forum/t...yte-array-to-32bit-integer.74957/#post-475969 Upvote 0
IntsFromBytes instead? You might need to transpose or... Maybe check this? https://www.b4x.com/android/forum/t...yte-array-to-32bit-integer.74957/#post-475969
Erel B4X founder Staff member Licensed User Longtime User May 18, 2017 #3 You can use the ToUnsigned sub to convert a signed byte to an int: https://www.b4x.com/android/forum/threads/signed-unsigned-bytes-confusion.61290/#post-386721 Upvote 0
You can use the ToUnsigned sub to convert a signed byte to an int: https://www.b4x.com/android/forum/threads/signed-unsigned-bytes-confusion.61290/#post-386721