long long hex into long long array

Sep 15, 2017 at 3:18am
I need help, I have a long long variable in hex. I want to convert them into a long long array so that I can access the individual hex value.
For example.
long long a = 0xA1B2C3;
I want to store it to array b so the output will look like this.
long long b[6];
b[0] = A
b[1] = 1
b[2] = B
b[3] = 2
b[4] = C
b[5] = 3
Can someone help me on this? TIA :) Im using C++
Sep 15, 2017 at 3:48am
an easy way is to print it to a string in hex format, then grab the characters, and convert back with a lookup table of the numeric values of the letters.
Sep 15, 2017 at 3:52am
These kinds of assignments exist to prove that you know how to take a number apart and put it back together.

Remember to use division and remainder, and a hex number as base/radix 16, not 10.
Sep 15, 2017 at 3:54am
number & 0xF would give you the last 4 bits
number / 16 would drop the last 4 bits
Sep 18, 2017 at 7:09am
Thanks for the information it helps me solve my problem :)
Topic archived. No new replies allowed.