On Sat, 08 Nov 2003 15:15:24 GMT, Tom MacIntyre
<(EMail Removed)> wrote:
>On Fri, 7 Nov 2003 22:08:27 0700, "Mark Stinson" <m
>(EMail Removed)> wrote:
>
>>There is the formula that I learned back in my skool daze, but it was a
>>royal pain, involved memorizing powers of 16 and doing a lot of math (which
>>may be why I learned it in a math class). Today, I convert decimal to
>>binary, then start from the right, split the binary into groups of four
>>digits and convert each group to one hex digit:
>>
>>38,463 = 1001 0110 0011 1111
>>
>>1001 0110 0011 1111
>> 9 6 3 F
>>
>>Alternatively (and more commonly), I open calc.exe in scientific mode, enter
>>my decimal number, click "hex" and viola!
>>
>>But if you really insist on doing it the hard way:
>>
>>The largest power of 16 that can be subtracted from 38,463 without getting a
>>negative result is 4096, so
>>
>>38,463 / 4096 = 9 with 1599 remainder
>>
>>1599 / 256 = 6 with 63 remainder
>>
>>63 / 16 = 3 with 15 remainder
>>
>>15 / 1 = 15 (F in hex) with 0 remainder
>>
>>So 38,463 = 963F
>>
>>And now you also know why you learned remainders in your math classes.
Since division is repeated subtraction, don't bother remembering
powers of 16. Stick with the same divisor throughout
1: Take a decimal number
2: Divide by 16  record, then ignore (for now) the remainder
3: Repeat step 2 until you have a number which is less than 16.
4: Start with that number, then write down the remainders in reverse
order to their generation. Convert remainders 10  15 to A  F of
course.
Voila!
Dead easy to program too  no need for a lookup table of poowers of
16.
[I learnt this method in school over 40 years ago. The education
system isn't getting any better]
Gordon
