Re: A86: .db numbers
[Prev][Next][Index][Thread]
Re: A86: .db numbers
At 09:52 PM 9/21/98 -0700, you wrote:
>
>JBrett wrote:
>> Yeah, what I want to know is how you got that byte from the number 45.
>
>The easiest way to convert bases is (in my opinion) modulo, if you're
doing in
>your head or by hand. I you know what a modulo is, you can stop here. If
not,
>read on.
<snip of explanation>
I always just do this:
Line up powers of 2 in your head (or on paper). Be sure to go to a power
that is greater than the number you are converting (45 in this example)
Then you look at the first power of 2, is it less than the base 10 number?
64 32 16 8 4 2 1
? ? ? ? ? ? ?
No, so in that place, put a 0.
64 32 16 8 4 2 1
0 ? ? ? ? ? ?
Repeat for the next digit. It is, so put a 1 there, and subtract the power
of 2 from the base number. 45-32=13.
64 32 16 8 4 2 1
0 1 ? ? ? ? ?
Then go to the next digit, a 0.
64 32 16 8 4 2 1
0 1 0 ? ? ? ?
and repeat until you get down to the ones place.
64 32 16 8 4 2 1
0 1 0 1 1 0 1
Great way to do it in your head, if you can get the powers of 2 straight.
--
Andy Johnson <prjohnson@utahlinx.com>
References: