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 ?
 
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

Similar Threads

  • Question Question
Android Question Hex to Decimal
Replies
9
Views
3K
  • Question Question
Android Question Hex string to Int
Replies
4
Views
5K
  • Article Article
Android Code Snippet [B4X] Hex string to number
Replies
0
Views
6K
  • Locked
  • Article Article
Replies
6
Views
10K
Back
Top