Android Question how to do copymemory like vb6

B4A send to vb6 :value a as long=165814
need bytes():182,135,2,0
but b4a send is:-74/-121/2/0
how to fix?
B4X:
    Dim v As Long = Bit.And(value, 0xFFFFFFFF)
    Dim b0 As Byte = Bit.And(v, 0xFF)
    Dim b1 As Byte = Bit.And(Bit.UnsignedShiftRight(v, 8), 0xFF)
    Dim b2 As Byte = Bit.And(Bit.UnsignedShiftRight(v, 16), 0xFF)
    Dim b3 As Byte = Bit.And(Bit.UnsignedShiftRight(v, 24), 0xFF)
 
Upvote 0
They are the same - its just how java has signed bytes - your code will show the same with a minor tweak
Code:
    Dim v As Long = Bit.And(value, 0xFFFFFFFF)
    Dim i_b0 As Int = Bit.And(v, 0xFF)
    Dim i_b1 As Int = Bit.And(Bit.UnsignedShiftRight(v, 8), 0xFF)
    Dim i_b2 As Int = Bit.And(Bit.UnsignedShiftRight(v, 16), 0xFF)
    Dim i_b3 As Int = Bit.And(Bit.UnsignedShiftRight(v, 24), 0xFF)

    Log( $" ${i_b3}, ${i_b2}, ${i_b1}, ${i_b0}")
 
Upvote 0
Back
Top