Android Question long to Hex

Lello1964

Well-Known Member
Licensed User
Longtime User
I have long prime number : 1287821 in Hex : 13A68D hex
must be converted in Hex in this format : 8DA613

How can i convert ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim bc As ByteConverter
bc.LittleEndian = True
Log(bc.HexFromBytes(bc.LongsToBytes(Array As Long(1287821))))
Output: 8DA6130000000000

If you want to remove the trailing zeroes:
B4X:
Dim s As String = bc.HexFromBytes(bc.LongsToBytes(Array As Long(1287821)))
Do While s.Length > 2 And s.SubString(s.Length - 2) = "00"
    s = s.SubString2(0, s.Length - 2)
Loop
Log(s)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…