Hi guys, I have one very basic doubt. Could somebody be kind enough to clear this. I still have problem to convert hexadecimal numbers to binary. ex:How to convert 0xff into binary number. Please teach me the trick. Giving the exam in couple of days. Any help would be highly appreciated. Thanks a bunch.

hi uma A short solution. first take the positional values for the one you are converting for e.g: a Hexadecimal can have 4096, 256, 16, 1 and then identify the exact decimal equivalent of the number or character from the Decimal- Hexadecimal representation chart..( you know from 0 to 9 the numbers are the same in Hexadecimal and 10-A, 11-B, 12-C, 13-D, 14-E, 15-F)assign & multiply with the Postional values. Finally add all those and you will get the decimal equivalent. eg: 0x0012 equivalent to 18. ( 1 * 16 + 2 * 1) i found this to be quick and hope this is of use to you Sathish

sathish
Ranch Hand

Joined: Apr 25, 2000
Posts: 33

posted

0

uma i thought you were asking to convert to decimal, Ok it's again simple Much simple Write the Hexadecimal digit or alphabet as it's 4-digit binary equivalent. e.g 0x0012 0000 0000 0001 0010 and you get 18. sathish

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

posted

0

Sathish: Your method is . Thanks. Now out of curiosity ...and necessity ... What abt 0xff which "uma" asked. Could you (or anyone else, I am sooooo generous ) help with this ... Thanks. - satya

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

posted

0

Thanks satish. But one more question are there going to be any questions like what's the result of 0x63^0xbd(i found this in apllied reasoning mock exam). Because it took way too much time for me to figure out answer to this q. First i had to convert those numbers to decimal format and then to binary format and then perform the calculation and then again convert the result into hexadecimal format. Could you please tell me some simple way to find out the answer for these kind of q's. Appoxmately how many q's of this type will be given in the test. Kindly help me with some detailed info. Thanks.

Satya, You have to know this by heart if you want to apply the easy method in order to convert a hex literal to an integer value. One technique I use generally is I can write upto 9 easily. After that I just add the extra values. In other words, If i have to write 'D' for example, I know 1001 is for 9, in order to get D I have to add(1+1+1+1) (A..B..C..D) which means I have to add 9+4 = 13 = 1101. <pre>

1 - 0000 2 - 0001 3 - 0010 4 - 0011 5 - 0100 6 - 0101 7 - 0110 8 - 0111 9 - 1000 A - 1010 B - 1011 C - 1100 D - 1101 E - 1110 F - 1111

</pre> So if you know this chart at your finger tips, then it is very easy to convert a hex to a binary. As Sathish said, <pre>

0xFF = 0x 1111 1111 = 255 as int value

I am sure you know how to convert binary to a number. All those bit0*(2^0) + bit1*(2^1)..... regds maha anna

Hi Uma Picking up from where Satish and Anna have stopped, it's obvoius that for ur case oxff, conversion from hex to binary will be 1111 1111. I believe u need not mug up the chart, as th binary conversion is pretty straigt forward. One more thing to add out here, if it's a conversion from octal to binary, use a set of three binary digits(2*2*2), instead of four binary digits(2*2*2*2) used for Hex numbers. All the best for your exams. I'll give it a shot in May end.

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

posted

0

As always ... Thanks Maha. Infact I was thinking of leaving all this stuff. There was a related discussion on "shifting" by Brian Nice. I wanted to ask abt conversion in that discussion, but took it easy ! I mean, howmuch ?? Now, I understand why some people (I talked to) said "oh, no its too much work for me...". hmmm...the exam is real real work .... Regds. - satya