Lello1964 Well-Known Member Licensed User Longtime User Jan 23, 2020 #1 I have long prime number : 1287821 in Hex : 13A68D hex must be converted in Hex in this format : 8DA613 How can i convert ?
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 Jan 23, 2020 #2 Code: 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: Code: 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
Code: 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: Code: 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)