A86: Re: HEX Conversion


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

A86: Re: HEX Conversion




If the other explanation didn't help, let me try to explain it a little
differently.  To understand hex, decimal, binary, octal, etc., all it takes
is that you understand how different math bases work.  I don't see why they
don't teach this in school, it's a simple yet important topic that should be
taught at about the Algebra I or II level.

The math that you are used to is decimal.  It's what you've always used.
Decimal is base 10.  The "base" is 10 because there are 10 digits in it
(0..9).  We probably started using it because we have 10 fingers/toes or
something like that.  But it could really have been anything.  In hex, you
have 16 digits.  Hexadecimal is base 16.  You have digits {0..9, A..F}.  In
another base, like binary, you only have 2 digits, 0 and 1.  So binary is
base 2.

The value of a number is found by summing up all of the digits.  The value
of each digit is found by multiplying the digit by the base raised to the
power of the position the digit is in the number.  The position moves right
to left starting at 0.  For example...

hex: 4AF     dig:   pos:  pos_val:  val:  (all in decimal for clarity)
     ||\----  15      0         1    15
     |\-----  10      1        16   160
     \------   4      2       256  1024
                                   ----
                                   1199

dec: 110101   dig:   pos:  pos_val:  val:  (again in decimal)
     |||||\-    1      0         1     1
     ||||\--    0      1         2     0
     |||\---    1      2         4     4
     ||\----    0      3         8     0
     |\-----    1      4        16    16
     \------    1      5        32    32
                                      --
                                      53

This is how the position values are determined:

dec:
     10 ^ 0 = 1
     10 ^ 1 = 10
     10 ^ 2 = 100

hex:
     16 ^ 0 = 1
     16 ^ 1 = 16
     16 ^ 2 = 256

bin:
     2 ^ 0 = 1
     2 ^ 1 = 2
     2 ^ 2 = 4
     2 ^ 3 = 8

Hope this helps,

--
David Phillips <electrum@tfs.net>
ICQ: 13811951
AOL/AIM: Electrum32
86 Central: http://www.tfs.net/~electrum/


-----Original Message-----
From: UnEven Software <uneven14@hotmail.com>
To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
Date: Saturday, December 12, 1998 1:19 AM
Subject: A86: HEX Conversion


>
>About 2 weeks ago I asked if someone could explain how to convert HEX
>numbers to decimal numbers.  Someone posted a routine to do this however
>what I wanted is how you actually do it.  Some sort of explanation on
>how to look at 3f and say "hmm thats 13" (or whatever that may be).  I
>know 1=1 (duh) 2=2 ... a=11 b=12 (right?) but how do you use the two
>together?  Is it the first times the second?  The first plus the second?
>If someone could explain this (NOT write a routine) I'd be thankful.
>
>
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.com