Re: A86: .db numbers


[Prev][Next][Index][Thread]

Re: A86: .db numbers




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.
A modulo is basically the remainder from division (remeber third grade
division?  15 / 4 = 3r3?).  Anyway, the way it works is this: divide the number
you're converting by the base (2 for binarry, 16 for hex, etc.).  For example,
45 would be 22r1.  Because the remainder is one, there is a 1 in the last
decimal place (%1).  You then subtract this from your number (45 - 1 = <gasp!>
44).  Then you divide by the next number in yout base (4 for binary, 32 for
hex).  44 / 4 = 11r0.  So, a zero goes in the next digit (%01).  44 / 8 = 5r1. 
%101, 44-4=40.  40 / 16 = 2r1.  %1101, 40-8=32.  32 / 32 = 1r0.  %01101.  32 /
64 = 0r1.  %101101, 32-32 = 0.  Then you add zeroes until it's 8 digits long -
%00101101 - and you're done.  The only trick part is remembering to subtract
only half of the number you divided by.
-- 
Dark Ryder
ICQ#:     8189903
E-Mail:   DarkRyder@cyberdude.com

Happiness is inversely proportional to how much you want to upgrade your
computer.

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/CC/ED/IT/M/MU/P/S/O/AT (!)d-? s++(+):+(++) a?--- C++++$
UB>L+++ P L>+++ E- W+++$ !N o? K- w(---)$ !O M(+)(-) V?
PS+(+++) PE-- Y PGP t*+(+++) 5++ X+ R*+++ tv b+++ DI++++
D++ G++>++++ e*>+++++ h!>++ r-(+) y**++
------END GEEK CODE BLOCK------


Follow-Ups: References: