1. Hex question

I know this is probably a stupid question...

x636F 6465 => Hex number

Can I look at each number/letter individually and write the corresponding decimal value? Since F is the only value which won't be identical, can I just insert 15 (it's corresponding decimal value) and have the number in decimal form? I want to convert it into binary....

2. Originally Posted by John_L
I know this is probably a stupid question...
Not stupid - but perhaps poorly phrased.

x636F 6465 => Hex number

Can I look at each number/letter individually and write the corresponding decimal value?
You can do anything you want. What's your overall objective?

Since F is the only value which won't be identical,...
Huh? Not sure I understand this. If I follow your logic, why isn't the 3 also unique???

...can I just insert 15 (it's corresponding decimal value) and have the number in decimal form?
Well, F is 15, if it's in the lowest nibble.

I want to convert it into binary....
Then all you need are bit patterns to replace the values. A little tight loop that spits out a 1 or a 0 based on the result of a BITWISE AND should work nicely. Test, output the 1 or 0, shift, repeat.

Todd

3. What about negative numbers if I were to use two's complement? -1 or -432 in hexadecimal form? I have the algorithm down for positive decimal numbers to hex and binary...not sure about the negative ones for hex though (binary is easy).

4. What do you care about negative numbers when converting from a base 16 representation of a base 2 number system?

5. Here's a way to convert a negative decimal number to a two-complement's hexadecimal representation
Code:
``` -1
=   < take the absolute value of -1, which is 1 >
1
=   < transform it in hexadecimal >
0x0001  (let's say we are working with 16-bits words)
=   < negate (one complement or 15 complement if you are staying in base 16) >
0xFFFE
0xFFFF```
Example with another number
Code:
``` -473
=
473
=
0x01D9
=
0xFE26
=
0xFE27```

6. Originally Posted by John_L
I know this is probably a stupid question...

x636F 6465 => Hex number

Can I look at each number/letter individually and write the corresponding decimal value? Since F is the only value which won't be identical, can I just insert 15 (it's corresponding decimal value) and have the number in decimal form? I want to convert it into binary....
What does decimal have to do with anything? Anyway, hex to binary is easy enough to do in your head: 636F6465 = 01100011011011110110010001100101