Author Topic:   Conversion umaunregistered posted April 27, 2000 03:58 PM            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. sathishgreenhorn posted April 27, 2000 04:32 PM              hi umaA short solution.first take the positional values for the one you are convertingfor 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 youSathish sathishgreenhorn posted April 27, 2000 04:41 PM              umai thought you were asking to convert to decimal, Ok it's again simpleMuch simpleWrite the Hexadecimal digit or alphabet as it's 4-digit binary equivalent.e.g 0x00120000 0000 0001 0010 and you get 18.sathish satya5ranch hand posted April 27, 2000 04:44 PM              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 umaunregistered posted April 27, 2000 04:47 PM            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. sreeranch hand posted April 27, 2000 04:53 PM              Satya,f is equal to 15 in hexadeciaml.So, 0xff will be 16^0*15+16^1*15.That would be 255 in decimal format. satya5ranch hand posted April 27, 2000 05:02 PM              Thanks sree.....I shold have known the case insensitivity ....(now I remember 0x?? 0X?? )phttt...too much caffine in my brain I guess - satya maha annabartender posted April 27, 2000 05:15 PM              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.` 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 `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,`0xFF = 0x 1111 1111 = 255 as int valueI am sure you know how to convert binary to a number. All those bit0*(2^0) + bit1*(2^1)..... regdsmaha anna ` Harry Chawlaunregistered posted April 27, 2000 10:17 PM            Hi UmaPicking 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. satya5ranch hand posted April 28, 2000 06:56 AM              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 thatdiscussion, 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 umaunregistered posted April 28, 2000 07:22 PM            Thanks a lot guys.
 |