{VERSION 5 0 "IBM INTEL NT" "5.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0
0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }
{CSTYLE "" -1 256 "" 0 1 0 128 0 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1
257 "" 0 1 0 128 0 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0
128 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 128 128 128 1
0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 128 1 0 0 0 0 0 0 0
0 0 0 }{CSTYLE "" -1 261 "" 0 1 0 0 128 1 0 0 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 262 "" 0 1 0 0 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1
263 "" 0 1 0 0 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0
0 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 0 1 0 0 128 1 0 0 0
0 0 0 0 0 0 0 }{CSTYLE "" -1 266 "" 0 1 0 0 128 1 0 0 0 0 0 0 0 0 0 0
}{CSTYLE "" -1 267 "" 0 1 0 0 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE ""
-1 268 "" 0 1 0 0 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 0 1
0 0 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 128 1 0 0
0 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0
0 0 }{CSTYLE "" -1 272 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 273 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE ""
-1 274 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 275 "" 0
1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 276 "" 0 1 0 128 128
1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 277 "" 0 1 0 128 128 1 0 1 0 0 0
0 0 0 0 0 }{CSTYLE "" -1 278 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 279 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1
280 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 281 "" 0 1 0
128 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 282 "" 0 1 0 128 128 1 0
0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 283 "" 0 1 0 128 128 1 0 1 0 0 0 0 0
0 0 0 }{CSTYLE "" -1 284 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 285 "" 0 1 0 128 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE ""
-1 286 "" 0 1 0 128 128 1 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 287 "" 0
1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 288 "" 0 1 0 128 128
1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 289 "" 0 1 0 128 128 1 0 1 0 0 0
0 0 0 0 0 }{CSTYLE "" -1 290 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 291 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE ""
-1 292 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 293 "" 0
1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 294 "" 0 1 0 128 128
1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 295 "" 0 1 0 128 128 1 0 1 0 0 0
0 0 0 0 0 }{CSTYLE "" -1 296 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 297 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE ""
-1 298 "" 0 1 0 128 128 1 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0
1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0
0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Time
s" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }
{PSTYLE "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1
2 2 2 2 1 1 1 1 }1 1 0 0 8 2 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 256
1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 1 1 1 1 }1 1 0 0
0 0 1 0 1 0 2 2 0 1 }}
{SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 257 34 "High School Modul
es > Precalculus\n" }}{PARA 3 "" 0 "" {TEXT -1 4 " " }{TEXT 256 12
"Number Bases" }}{PARA 0 "" 0 "" {TEXT -1 87 "\nAn exploration of alte
rnative number bases, conversions, and even decimal expansions.\n" }}
{PARA 0 "" 0 "" {TEXT 258 153 "[Directions : Execute the Code Resource
section first. Although there will be no output immediately, these de
finitions are used later in this worksheet.]" }}{PARA 0 "" 0 "" {TEXT
-1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }{TEXT 260 7 "0. Code
" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "restart; " }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 252 "#=================================
==========================\nprintbase := proc( dec_num, bs)\n local \+
x,n;\n x := convert( dec_num, base, bs );\n n := nops(x); \n pr
int( cat(dec_num,` = `,seq( x[n-i+1], i = 1..n),` ` ) \+
);\nend proc :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 730 "#=======
====================================================\nprint2base := pr
oc( dec_num, bs1, bs2 )\n local x,n, y, m, k;\n x := convert( dec_
num, base, bs1 );\n n := nops(x);\n if(bs1 = 16) then for k from 1
to n do\n if(x[k] = 10) then x[k] :=`A`; fi;\n if(x
[k] = 11) then x[k] :=`B`; fi;\n if(x[k] = 12) then x[k] :=`C
`; fi;\n if(x[k] = 13) then x[k] :=`D`; fi;\n if(x[k
] = 14) then x[k] :=`E`; fi;\n if(x[k] = 15) then x[k] :=`F`;
fi;\n od;fi;\n \n y := convert( dec_num, base, bs2 );\n m := \+
nops(y); \n print( cat(dec_num,` = `,seq( x[n-i+1], i = 1..n),` = `,\n seq( y[m-i+1], i = 1..m
),` ` ) );\nend proc :\n" }}}{EXCHG {PARA 0 "> " 0 "
" {MPLTEXT 1 0 637 "#=================================================
==========\nbasefraction := proc(num, bse, places)\n local k, kstart
, x,q,xint,xdec,n,m;\n x := num;\n xint := []; xdec := []; \n \+
kstart := round(log[bse](x));\n for k from kstart to 0 by -1 do \n \+
q := floor( x / bse^k); \n x := x - q* bse^k;\n xint := [op
(xint),q]; \n od;\n\n for k from -1 to -places by -1 do \n \+
q := floor( x / bse^k);\n x := x - q* bse^k;\n xdec := \+
[op(xdec),q]; \n od;\n n := nops(xint); m := nops(xdec);\n p
rint( cat( seq( xint[i], i = 1..n),`.`, \n seq( xdec[m-i
+1], i = 1..m),` `));\nend proc:\n" }}}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 60 "#============================================
===============" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }{TEXT
261 25 "1. What Are Number Bases?" }}{PARA 0 "" 0 "" {TEXT -1 271 "\nI
n our normal base 10 number system, which is called the decimal system
, we have 10 digits : 0, 1, 2, ...9. There is no single symbol for the
number one larger than nine, ten. We use two digits to represent this
number, and so forth. The \"1\" in \"10\" represents one ten.\n" }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "for k from 1 to 12 do k; od;
" }}}{PARA 0 "" 0 "" {TEXT -1 78 "\nEventually we need three digits. T
he \"1\" in \"100\" represents one ten squared." }}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 30 "for k from 96 to 102 do k; od;" }}}{PARA 0 ""
0 "" {TEXT -1 112 "\nWhat does the expression, 732 mean? Just as we c
an express an integer as a sum of numbers times powers of 10.\n" }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "732 = `700` + `30`+ `2`;" }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "732 = `7 * 10^2` + `3
* 10^1`+ `2 * 10^0` ;" }}}{PARA 0 "" 0 "" {TEXT -1 36 " \nIn genera
l, a five digit integer, " }{XPPEDIT 18 0 "a[5]" "6#&%\"aG6#\"\"&" }
{XPPEDIT 18 0 "a[4]" "6#&%\"aG6#\"\"%" }{XPPEDIT 18 0 "a[3]" "6#&%\"aG
6#\"\"$" }{XPPEDIT 18 0 "a[2]" "6#&%\"aG6#\"\"#" }{XPPEDIT 18 0 "a[1]
" "6#&%\"aG6#\"\"\"" }{XPPEDIT 18 0 "a[0]" "6#&%\"aG6#\"\"!" }{TEXT
-1 30 ", can be expressed in this way" }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 47 "a:= 'a': k:= 'k':\nsum( a[k]*`10`^k, k = 0..5);" }}}
{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 248 "\nOur en
tire number system is based on 10 digits. However, this same process c
an occur with other number bases. Lets use base 7 as a an example. Thi
s means we will have digits 0, 1, 2, 3, 4, 5, 6. The number \"7\" will
require two digits to represent." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 43 "for k from 1 to 16 do printbase( k, 7); od;" }}}
{PARA 0 "" 0 "" {TEXT -1 11 "\nA number, " }{XPPEDIT 18 0 "a[5]" "6#&%
\"aG6#\"\"&" }{XPPEDIT 18 0 "a[4]" "6#&%\"aG6#\"\"%" }{XPPEDIT 18 0 "a
[3]" "6#&%\"aG6#\"\"$" }{XPPEDIT 18 0 "a[2]" "6#&%\"aG6#\"\"#" }
{XPPEDIT 18 0 "a[1]" "6#&%\"aG6#\"\"\"" }{XPPEDIT 18 0 "a[0]" "6#&%\"a
G6#\"\"!" }{TEXT -1 61 " considered to be in base 7, represents the fo
llowing number." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "a:= 'a': \+
k:= 'k':\nsum( a[k]*`7`^k, k = 0..5);" }}}{PARA 0 "" 0 "" {TEXT -1
72 "\n\nWhen we look at numbers base 3, we only have 3 digits : 0, 1, \+
and 2. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "for k from 1 to \+
16 do printbase( k, 3); od;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
46 "a:= 'a': k:= 'k':\nsum( a[k]*`3`^k, k = 0..5);" }}}{PARA 0 "" 0 "
" {TEXT -1 2 "\n " }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }{TEXT
262 41 "2. Converting from Other Bases to Decimal" }}{PARA 0 "" 0 ""
{TEXT -1 216 "\nIf we are given a number in another base, its not too \+
difficult to convert it back to decimal, if we remember what the digit
s of the number in the other base mean. A four digit number in base 7 \+
means the following.\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "'a
[3]','a[2]','a[1]','a[0]',` ` = sum( a[k]*`7`^k, k = 0..3);
" }}}{PARA 0 "" 0 "" {TEXT -1 11 "\n\n " }{TEXT 271 12 "Exampl
e 2.1:" }{TEXT -1 137 " Express 23 in decimal.\n\n3 is in th
e 1's place, and 2 is in the 7's place. So we just write out a sum lik
e this, and verify it." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "2*7
+ 3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "printbase( 17, 7);
" }}}{PARA 0 "" 0 "" {TEXT -1 9 "\n " }{TEXT 273 12 "Example 2.
2:" }{TEXT -1 137 " Express 54 in decimal.\n\n4 is in the 1'
s place, and 5 is in the 7's place. So we just write out a sum like th
is, and verify it." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "5*7 + 4
;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "printbase( 39, 7);" }}
}{PARA 0 "" 0 "" {TEXT -1 10 "\n\n " }{TEXT 272 12 "Example 2.3
:" }{TEXT -1 122 " Express 416 in decimal.\n\nThis number ha
s three digits. These numbers represent the number of 1's, 7's and 49'
s." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "4*7^2 + 1*7 + 6;" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "printbase( 209, 7);" }}}
{PARA 0 "" 0 "" {TEXT -1 8 "\n \n " }{TEXT 274 12 "Example 2.4:" }
{TEXT -1 156 " Express 416 in decimal.\n\nSame number as ab
ove, but a different base. So we expand it in the same way, but use th
e different base for the powers." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 18 "4*13^2 + 1*13 + 6;" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " \+
" }{TEXT 263 41 "3. Converting from Decimal to Other Bases" }}{PARA 0
"" 0 "" {TEXT -1 97 "\nIts slightly harder to convert from decimal to \+
another base. Lets go through an example.\n\n\n " }{TEXT 275 12 "E
xample 3.1:" }{TEXT -1 160 " Express the decimal number 29 in base 9.
\n\nWe can find the answer quickly using this function. The answer is \+
32 . But how can find that for ourselves?\n" }}{EXCHG {PARA 0
"> " 0 "" {MPLTEXT 1 0 18 "printbase( 29, 9);" }}}{PARA 0 "" 0 ""
{TEXT -1 221 "\nWe find the largest power of 9 that goes into 29 but d
oes not exceed it. In this case, that power is 9^1. When we divide by \+
9 (throwing away any remainder for now), we get 3. This is the first d
igit our number in base 9." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
80 "dec_num := 29;\nfloor( dec_num/ 9^3);\nfloor( dec_num/ 9^2);\nfloo
r( dec_num/ 9^1);" }}}{PARA 0 "" 0 "" {TEXT -1 160 "\nThis means that \+
3 is the digit in the \"9's\" place. We take 3*9^1 away from our numbe
r, what's left over are the number of ones. This gives us the whole nu
mber." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "dec_num - 3*9^1;\np
rint(`29 = 32 `);" }}}{PARA 0 "" 0 "" {TEXT -1 2 " " }}{PARA
0 "" 0 "" {TEXT 276 15 " Example" }{TEXT 281 1 " " }{TEXT 277
4 "3.2:" }{TEXT 282 2 " " }{TEXT -1 306 "Express the decimal number 7
8 in base 4.\n\nWe follow the same procedure as above. Find the greate
st power of 4 that does not exceed the number, and divide that power i
nto the number to get a digit. Then take the difference, and continue \+
with smaller and smaller powers of 4, until we get to the ones place.
\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 102 "dec_num := 78;\nfloor
( dec_num/ 4^4);\nfloor( dec_num/ 4^3);\nfloor( dec_num/ 4^2);\nfloor(
dec_num/ 4^1);" }}}{PARA 0 "" 0 "" {TEXT -1 167 " \nThe largest power
of 4 that goes into 78 is 4^3, and it goes in, 1 time. The first digi
t is 1. Now look at the difference, and divide by the next smaller pow
er of 4." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "dec_num - 1*4^3;
\nfloor( %/ 4^2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "%% - 0
*4^2;\nfloor( %/ 4^1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "%
% - 3*4^1;\nfloor( %/ 4^0);" }}}{PARA 0 "" 0 "" {TEXT -1 86 "\nSo the \+
digits are 1032 . Lets check.\n\nWe can check using this fun
ction, ..." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "printbase( 78,
4);" }}}{PARA 0 "" 0 "" {TEXT -1 95 "\n ... or Maple's built in co
nverter, which gives us the digits as a list, in inverted order." }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "convert( 78, base, 4 );" }}}
{PARA 0 "" 0 "" {TEXT -1 2 "\n " }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1
1 " " }{TEXT 264 9 "4. Binary" }}{PARA 0 "" 0 "" {TEXT -1 51 "\nOne sp
ecial number is base 2, which is called the " }{TEXT 278 6 "binary" }
{TEXT -1 288 " number system. Every binary number is made up only 0's \+
and 1's. This is a very simple system, but one which is immensely impo
rtant - especially in the design and operation of computers where the \+
smallest storage unit on a hard disk or in ram is a bit which is eithe
r on or off... 0 or 1." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "fo
r k from 0 to 16 do printbase( k, 2); od;" }}}{PARA 0 "" 0 "" {TEXT
-1 81 "\nNote that the powers of 2 are the \"10\", \"100\", \"1000\", \+
etc. of this number base." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45
"for k from 0 to 20 do printbase( 2^k, 2); od;" }}}{PARA 0 "" 0 ""
{TEXT -1 111 "\nMaple has a built-in command to quickly convert from d
ecimal to binary, or vice-versa, from binary to decimal." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "convert( 59,binary);" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "convert( 111011, decimal, binary \+
);" }}}{PARA 0 "" 0 "" {TEXT -1 2 "\n " }}}{SECT 1 {PARA 4 "" 0 ""
{TEXT -1 1 " " }{TEXT 265 8 "5. Octal" }}{PARA 0 "" 0 "" {TEXT -1 76 "
\nOne problem with the binary system is that the numbers get so big so
fast. " }{TEXT 279 5 "Octal" }{TEXT -1 537 ", base 8, is a way to get
a better grip on binary numbers because every three binary digits can
be transformed into a single octal digit. Thus a 21 digit binary numb
er can be expressed as a 7 digit octal number. In computer usage, ever
y 3 bits can be represented by a single octal character. For example, \+
64 bit word, would take 64 binary digits to represent, or 22 octal dig
its. Its not just the smaller number of digits, but also the fact that
you can convert binary to octal and vice-versa directly in your head \+
without any formula.\n " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "f
or k from 1 to 16 do print2base( k, 2, 8); od;" }}}{PARA 0 "" 0 ""
{TEXT -1 81 "\nNote that the powers of 8 are the \"10\", \"100\", \"10
00\", etc. of this number base." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 44 "for k from 0 to 6 do printbase( 8^k, 2); od;" }}}{PARA 0 "" 0
"" {TEXT -1 105 "\nNote that every three zeroes in the binary represen
tation are a single zero in the octal representation." }}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 49 "for k from 0 to 10 do print2base( 8^k, 8,
2); od;" }}}{PARA 0 "" 0 "" {TEXT -1 112 "\n\n\n\nMaple has a built-i
n command to quickly convert from decimal to octal, or vice-versa, fro
m octal to decimal." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "conve
rt( 59,octal);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "convert( \+
73, decimal, octal );" }}}{PARA 0 "" 0 "" {TEXT -1 80 "\n\nYou can c
onvert from octal to binary by passing through the decimal expansion.
" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "convert( 73, decimal, \+
octal );\nconvert( %, binary);" }}}{PARA 0 "" 0 "" {TEXT -1 54 "\nYou \+
can convert from binary to octal in this way too." }}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 58 "convert( 1001001, decimal, binary );\nconve
rt( %, octal);" }}}{PARA 0 "" 0 "" {TEXT -1 2 "\n " }}}{SECT 1 {PARA
4 "" 0 "" {TEXT -1 1 " " }{TEXT 267 14 "6. Hexadecimal" }}{PARA 0 ""
0 "" {TEXT -1 1 "\n" }{TEXT 280 11 "Hexadecimal" }{TEXT -1 810 " is ba
se 16, and is even more useful than octal in representing binary numbe
rs in a concise way. This is because each hexadecimal symbol represent
s 4 bits, or 4 binary digits. A 64 bit storage location can be stored \+
with 64 bits, or \"16 hex\" symbols. This is a much more readable form
of binary. And like octal, its not too hard to convert from binary to
hex and back on the spot without formulas.\n\nOne problem with hex, t
hat was not encountered with octal and binary, is that 16 is larger th
an 10, the base of our decimal system. This means we need 16 single sy
mbols, but our decimal number system only provides 10 - we are six sho
rt. To make up for the shortage, it is customary to employ the first 6
letters of the alphabet :\n A = 10, B = 11, C =
12, D = 13, E = 14, F = 15 \n\n" }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 42 "for k from 1 to 15 do convert(k,hex); od;\n" }}}
{PARA 0 "" 0 "" {TEXT -1 129 "\nWe use these letters just like numbers
. It takes a little getting used to seeing this strings of numbers and
letters as numbers." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "for \+
k from 1 to 32 do print2base( k, 16, 2); od;" }}}{PARA 0 "" 0 ""
{TEXT -1 170 "\nNote that the powers of 16 are the \"10\", \"100\", \"
1000\", etc. of the hex base. Note that each 0 in the hex number corre
sponds to four zeroes in the binary representation." }}{EXCHG {PARA 0
"> " 0 "" {MPLTEXT 1 0 50 "for k from 0 to 6 do print2base( 16^k, 16, \+
2); od;" }}}{PARA 0 "" 0 "" {TEXT -1 111 "\n\n\nMaple has a built-in c
ommand to quickly convert from decimal to octal, or vice-versa, from o
ctal to decimal." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "convert(
59, hex);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "convert( 200,
hex);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "convert( 1000, de
cimal, hex );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "convert(
A0B0C, decimal, hex );" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0
"" 0 "" {TEXT -1 319 "\nConversions between binary and octal, and bina
ry and hex are simple and can be done on inspection because each three
binary digits can be represented by one octal digit, and each four bi
nary digits can be represented by a single hex digit. However, the con
versions from octal to hex are usually not particularly nice. " }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "print2base( 333, 16, 8);" }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "print2base( 1000, 16, 8);"
}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "print2base( 1121210, 16, \+
8);" }}}{PARA 0 "" 0 "" {TEXT -1 60 "\nExcept when the number is a pow
er of two or near to one...." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
24 "print2base( 512, 16, 8);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1
0 24 "print2base( 257, 16, 8);" }}}{PARA 0 "" 0 "" {TEXT -1 2 "\n " }}
}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }{TEXT 269 19 "7. Computer Sto
rage" }}{PARA 0 "" 0 "" {TEXT -1 166 "\nSince all computer storage are
based on binary, the sizes uses for hard disks, ram (random access me
mory), CD Rom, etc, is often measured in convenient powers of 2.\n" }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "`1 k` = 2^10;" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "`1 meg` = 2^20;" }}}{EXCHG {PARA 0
"> " 0 "" {MPLTEXT 1 0 15 "`1 gig` = 2^30;" }}}{PARA 0 "" 0 "" {TEXT
-1 71 "\n You might notice that 1 meg, is 1 k squared, and 1 gig is 10
24 megs.\n" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }{TEXT 270 22 "8
. Decimals in Decimal" }}{PARA 0 "" 0 "" {TEXT -1 162 "\nWhat does the
expression, 732.145 mean? Just as we can express an integer as a sum
of numbers times powers of 10, we can extend this to negative exponen
ts too.\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "732.145 = `700`
+ `30`+ `2`+ `0.1`+ `0.04`+ `0.005`;" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 116 "732.145 = `7 * 10^2` + `3 * 10^1`+ `2 * 10^0
` + \n `1 * 10^(-1)` + `1 * 10^(-2)`+ `1 * 10^(-3)`;" }}}
{PARA 0 "" 0 "" {TEXT -1 26 " \nIn general, an integer, " }{XPPEDIT
18 0 "a[5]" "6#&%\"aG6#\"\"&" }{XPPEDIT 18 0 "a[4]" "6#&%\"aG6#\"\"%"
}{XPPEDIT 18 0 "a[3]" "6#&%\"aG6#\"\"$" }{XPPEDIT 18 0 "a[2]" "6#&%\"a
G6#\"\"#" }{XPPEDIT 18 0 "a[1]" "6#&%\"aG6#\"\"\"" }{XPPEDIT 18 0 "a[0
]" "6#&%\"aG6#\"\"!" }{TEXT -1 30 ", can be expressed in this way" }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "a:= 'a': k:= 'k':\nsum( a[k
]*`10`^k, k = 0..5);" }}}{PARA 0 "" 0 "" {TEXT -1 36 "\nIn the same wa
y, a decimal number, " }{XPPEDIT 18 0 "a[4]" "6#&%\"aG6#\"\"%" }
{XPPEDIT 18 0 "a[3]" "6#&%\"aG6#\"\"$" }{XPPEDIT 18 0 "a[2]" "6#&%\"aG
6#\"\"#" }{XPPEDIT 18 0 "a[1]" "6#&%\"aG6#\"\"\"" }{XPPEDIT 18 0 "a[0]
" "6#&%\"aG6#\"\"!" }{TEXT -1 1 "." }{XPPEDIT 18 0 "a[-1]" "6#&%\"aG6#
,$\"\"\"!\"\"" }{XPPEDIT 18 0 "a[-2]" "6#&%\"aG6#,$\"\"#!\"\"" }{TEXT
-1 30 ", can be expressed in this way" }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 48 "a:= 'a': k:= 'k':\nsum( a[k]*`10`^k, k = -2..4);" }}
}{PARA 0 "" 0 "" {TEXT -1 58 "\nCan we extend this same thinking to ot
her number bases?\n " }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }
{TEXT 268 22 "9. Fractions in Binary" }}{PARA 0 "" 0 "" {TEXT -1 99 "
\nIn the same way that we used negative powers base 10, we can do the \+
same thing in binary, base 2.\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 68 "for k from -4 to 5 do 1/2^k = convert( .5^k, binary),`
`; od;" }}}{PARA 0 "" 0 "" {TEXT -1 1 "\n" }{TEXT 293 25 "\n Ex
ample 9.1 : " }{TEXT -1 152 "Express 3/4 in base 2\n\nSince 1/2 = .1
, and 1/4 = .01 , if we add 1/2 and 3/4, we should be
able to add .10 and .01 to get .11 ." }}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 53 "1/2 + 1/4 : %= convert( evalf(%), binary),``;" }}}{PARA 0 "" 0 "" {TEXT -1 1 "\n" }{TEXT 294 23 " Exampl
e 9.2 : " }{TEXT -1 62 "Express 7/8 in base 2\n\nIf we add the next \+
power of 2, 1/8 ...." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "1/2 \+
+ 1/4 +1/8: %= convert( evalf(%), binary),``;" }}}{PARA 0 ""
0 "" {TEXT -1 1 "\n" }{TEXT 295 23 " Example 9.3 : " }{TEXT
-1 65 "Express 15/16 in base 2\n\nIf we add the next power of 2, 1/16 \+
...." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "1/2 + 1/4 + 1/8 + 1/
16: %= convert( evalf(%), binary),``;" }}}{PARA 0 "" 0 ""
{TEXT -1 1 "\n" }{TEXT 296 23 " Example 9.4 : " }{TEXT -1 65 "
Express 31/32 in base 2\n\nIf we add the next power of 2, 1/32 ...." }
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "1/2 + 1/4 +1/8 + 1/16 + 1/3
2: %= convert( evalf(%), binary),``;" }}}{PARA 0 "" 0 ""
{TEXT -1 1 "\n" }{TEXT 297 23 " Example 9.5 : " }{TEXT -1 66 "
Express 63/64 in base 2\n\nIf we add the next power of 2, 1/64 ...."
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "1/2 + 1/4 +1/8 + 1/16 + 1
/32 + 1/64: %= convert( evalf(%), binary),``;" }}}{PARA 0 ""
0 "" {TEXT -1 107 "\n Any decimal number in base 10 can be expressed a
s a decimal in binary...although they may be infinite.\n \n" }{TEXT
298 23 " Example 9.4 : " }{TEXT -1 120 "Express 1/3, 1/4, 1/5,
1/6, 1/7 in base 2\n\nNotice that only one of these has a terminating
decimal. Can you explain why?" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1
0 47 "1/3: %= convert( evalf(%), binary),``;" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "1/4: %= convert( evalf(%), binary)
,``;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "1/5: %= co
nvert( evalf(%), binary),``;" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 47 "1/6: %= convert( evalf(%), binary),``;" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "1/7: %= convert( evalf(%), \+
binary),``;" }}}{PARA 0 "" 0 "" {TEXT 292 25 "\n Exampl
e 9.5 : " }{TEXT -1 129 "Express sqrt(2) in base 2 to 20 places.\n\n
We'll use the same process, but we'll automate it to take the drudgery
out of the chore." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "sqrt(2
): %= convert( evalf(%), binary),``;" }}}{PARA 0 "" 0 ""
{TEXT -1 68 "\nGood, but not enough decimal places. Lets try this cust
om function." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "basefraction
(evalf(sqrt(2)), 2, 30);" }}}{PARA 0 "" 0 "" {TEXT -1 144 "\nIs there \+
any pattern? Hopefully not, since sqrt(2) is an irrational number... w
hich means irrational in all number bases, not just in base 10!\n" }}}
{SECT 1 {PARA 4 "" 0 "" {TEXT -1 1 " " }{TEXT 266 28 "10. Fractions in
Other Bases" }}{PARA 0 "" 0 "" {TEXT -1 143 "\nOf course, we can do t
he same thing in other number bases. Any decimal number base 10 can be
represented by decimals in other number bases. \n\n" }{TEXT 283 14 " \+
Example" }{TEXT 285 1 " " }{TEXT 284 6 "10.1 :" }{TEXT 286 2 " \+
" }{TEXT -1 111 "Express 10 4/7 in base 7.\n\nThis is a set up of cour
se because we are given a denominator with 7 already in it.\n" }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "`10 1/7` = cat( 1, 3, `.`,4,
` `);" }}}{PARA 0 "" 0 "" {TEXT -1 55 "\nOK, lets do one with \+
a only little more substance. \n\n" }}{PARA 0 "" 0 "" {TEXT 287 24 " \+
Example 10.2 : " }{TEXT -1 333 "Express 5 25/49 in base 7.\n
\nAlthough it looks a bit different we use the same procedure we used \+
to make conversions of integers above. Divide by the largest power of \+
7 that divides the number, take the difference, and continue the proce
ss. The 5 is already the 1's digit (7^0). As we progress to the next s
maller exponent, we go to " }{XPPEDIT 18 0 "7^(-1)" "6#)\"\"(,$\"\"\"!
\"\"" }{TEXT -1 13 ", and divide." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 28 "floor( (25/49) / (7^(-1)) );" }}}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 14 "(25/49) - 3/7;" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 41 "`5 25/49` = cat( 5, `.`,34,` `);" }}}{PARA
0 "" 0 "" {TEXT 288 24 " \n\n Example 10.3 : " }{TEXT -1 37 "Expr
ess 1/2 in base 7.\n\nSame process." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 46 "1/2;\nfloor( % / (7^(-1)) );\n%% - %*(7^(-1)); \n" }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "floor( % / (7^(-2)) );\n%% \+
- %*(7^(-2));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "floor( % /
(7^(-3)) );\n%% - %*(7^(-3));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 26 "basefraction( 1/2, 7, 12);" }}}{PARA 0 "" 0 "" {TEXT -1 124 "W
e seem to have encountered a pattern. 1/2 has an infinite decimal in b
ase 7, although it has a terminating decimal base 10." }}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 27 "`1/2` = `.333... `;" }}}{PARA 0 "
" 0 "" {TEXT 289 28 "\n\n\n Example 10.3 : " }{TEXT -1 123 "E
xpress \271 in base 7 to 12 places.\n\nWe'll use the same process, but
we'll automate it to take the drudgery out of the chore." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "Pi; evalf(%, 30): \nbasefraction(%,
7, 12);" }}}{PARA 0 "" 0 "" {TEXT 290 28 "\n\n\n Example 10.4 \+
: " }{TEXT -1 123 "Express \271 in base 3 to 20 places.\n\nWe'll use
the same process, but we'll automate it to take the drudgery out of t
he chore." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "Pi; evalf(%); \+
\nbasefraction(%, 3, 20);" }}}{PARA 0 "" 0 "" {TEXT 291 27 "\n\n \+
Example 10.5 : " }{TEXT -1 129 "Express sqrt(3) in base 3 to 30 pl
aces.\n\nWe'll use the same process, but we'll automate it to take the
drudgery out of the chore." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
43 "sqrt(3); evalf(%); \nbasefraction(%, 2, 30);" }}}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 0 "" }}}}{PARA 0 "" 0 "" {TEXT 259 73 "\n \+
\251 2002 Waterloo Maple Inc & Gregory Moore, all rights reserved." }
}}{MARK "17" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2
33 1 1 }