Hi All
I have a conversion problem.
I have a value from 0 to 1023 stored in Short integer and I need to extract high and low byte from it and store it as Char so I tried following:
results I get in Log are following:
1023: 0000001111111111
High byte: 3 Low byte: 2
771: 0000001100000011
High byte: 3 Low byte: 3
669: 0000001010011101
High byte: 2 Low byte: 1
** Activity (main) Pause, UserClosed = false **
So.. my question is what am I doing wrong?
Thanks
I have a conversion problem.
I have a value from 0 to 1023 stored in Short integer and I need to extract high and low byte from it and store it as Char so I tried following:
B4X:
Sub Globals
...
Dim servo1() As Short
Dim servo1H As Char
Dim servo1L As Char
...
End Sub
Sub btnSend_Click
servo1L = Bit.And(servo1(0),0xFF)
servo1H = Bit.ShiftRight(Bit.And(servo1(0),0xF00), 8)
Log(servo1(0)&": "&int2Bin(servo1(0),16))
Log ("High byte: "&servo1H&" Low byte: "&servo1L)
End Sub
results I get in Log are following:
1023: 0000001111111111
High byte: 3 Low byte: 2
771: 0000001100000011
High byte: 3 Low byte: 3
669: 0000001010011101
High byte: 2 Low byte: 1
** Activity (main) Pause, UserClosed = false **
So.. my question is what am I doing wrong?
Thanks