M Mostez Well-Known Member Licensed User Longtime User May 8, 2017 #1 I want to convert Ulong (264733) to hex string, to send to USB host module(VNC1L), any Ideas Thanks
Erel B4X founder Staff member Licensed User Longtime User May 8, 2017 #2 B4X: Dim bc As ByteConverter Log(bc.HexFromBytes(bc.ULongsToBytes(Array As ULong(264733)))) Upvote 0
M Mostez Well-Known Member Licensed User Longtime User May 8, 2017 #3 result is = 1D0A0400, it should be 40A1D. it looks like rotated bytes inside word Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 9, 2017 #4 ByteConverter uses little endian. You can instead use RandomAccessFile: B4X: Dim raf As RandomAccessFile Dim b(4) As Byte raf.Initialize(b, False) 'false = big endian raf.WriteULong32(264733, 0) Dim bc As ByteConverter Log(bc.HexFromBytes(b)) Upvote 0
ByteConverter uses little endian. You can instead use RandomAccessFile: B4X: Dim raf As RandomAccessFile Dim b(4) As Byte raf.Initialize(b, False) 'false = big endian raf.WriteULong32(264733, 0) Dim bc As ByteConverter Log(bc.HexFromBytes(b))