Android Question How to get LoWord and HiWord of an Int

wbtcpip

Member
Licensed User
Longtime User
Having an Int value how i get the LowWord and HighWord value?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim s() As Short = IntToShorts(0xabcdef12)
'test it
Log(Bit.ToHexString(Bit.And(0xffff,s(0)))) 'convert to unsigned short
Log(Bit.ToHexString(Bit.And(0xffff,s(1))))
End Sub

Sub IntToShorts (i As Int) As Short()
   Return Array As Short( _
     Bit.And(0xFFFF, i), _
     Bit.And(0xFFFF, Bit.ShiftRight(i, 16)))
End Sub
 
Upvote 0
Top