Question 1:Which is the fastest way to convert an integer to byte array?
a = 1026
aHexStr = string(a,base = 16,pad = 4) #2 bytes, 4 chars
b = zeros(UInt8,2)
k = 1
for i in 1:2:4
b[k] = parse(UInt8,aHexStr[i:i+1],base = 16)
k += 1
end
Is this method the fastest?
Related Question 2: Which is the fastest way to convert a hexadecimal string to byte array?
I have a string of hexadecimal numbers
a = "ABCDEF12345678"
How can I convert this hex string to byte array?
b = zeros(UInt8,7)
k = 1
for i in 1:2:14
b[k] = parse(UInt8,a[i:i+1],base = 16)
k += 1
end
Is this method the fastest?