# Thread: Hex Values - C

1. ## Hex Values - C

hi,
I have to write a C program which takes a 64bit hex number, splits it into its lower and higher halves and then converts them to binary.

my problem is for example

if the 64 bit hex number = [aa,bb,cc,dd,ee,ff,ab,ac]

which are the lower bits...does it start from [dd,cc,bb,aa] or is it from [aa,bb,cc,dd]. How should I read the hex values??

If anyone could clear this up for me I would greatly appreciate it.......
takes a million
Dee

2. It's a matter of protocol...how do you get input and display output for this program?

Personally, this way is most intuitive...
64 bit hex number = [aa,bb,cc,dd,ee,ff,ab,ac]
upper half = [aa,bb,cc,dd]
lower half = [ee,ff,ab,ac]

3. The hex values are coded into arrays.

But I thought Hex values were read left to right!!!!! and binary read right to left!!!

4. Like I said, it's a matter of protocol. Unless this is somehow hardware-related, I suggest that you do it so that the most significant digit is on the left.

5. Like QuestionC says, it's just matter of protocol. In other words, it's a matter of how you define which bit is on which place.

As I understand you have a 64 bit value. Let's define that the value is defined as follows (in bits):

b63 b62 ...... b1 b0

This can be grouped in bytes as follows:

B7 B6 ... B1 B0

Let us now define an array for storing the 64 bit value, where each byte is stored as a hexadecimal value:

hex_array = [H7, H6, H5, H4, H3, H2, H1, H0]