How to turn this simple 10 digit hex number back into 8 digits?
- by Babil
The algorithm to convert input 8 digit hex number into 10 digit are following:
Given that the 8 digit number is: '12 34 56 78'
x1 = 1 * 16^8 * 2^3
x2 = 2 * 16^7 * 2^2
x3 = 3 * 16^6 * 2^1
x4 = 4 * 16^4 * 2^4
x5 = 5 * 16^3 * 2^3
x6 = 6 * 16^2 * 2^2
x7 = 7 * 16^1 * 2^1
x8 = 8 * 16^0 * 2^0
Final 10 digit hex is:
= x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8
= '08 86 42 98 E8'
The problem is - how to go back to 8 digit hex from a given 10 digit hex (for example: 08 86 42 98 E8 to 12 34 56 78)
Some sample input and output are following:
input output
11 11 11 11 08 42 10 84 21
22 22 33 33 10 84 21 8C 63
AB CD 12 34 52 D8 D0 88 64
45 78 96 32 21 4E 84 98 62
FF FF FF FF 7B DE F7 BD EF