2010.1012 ch2.2 CPU & Memory

4057 days ago by calcpage123

def sum(n): x=1 s=0 while x<=n: s=s+x x=x+1 return s sum(6) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}21
\newcommand{\Bold}[1]{\mathbf{#1}}21
#3) giga = 1000000000 = 1000**3 vs. mega = 1000000 = 1000**2 a=120*10**9 b=512*10**6 show(a) show(b) show(n(a/b)) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}120000000000
\newcommand{\Bold}[1]{\mathbf{#1}}512000000
\newcommand{\Bold}[1]{\mathbf{#1}}234.375000000000
\newcommand{\Bold}[1]{\mathbf{#1}}120000000000
\newcommand{\Bold}[1]{\mathbf{#1}}512000000
\newcommand{\Bold}[1]{\mathbf{#1}}234.375000000000
#3) gibi = 1024**3 = (2**10)**3 vs. mebi = 1024**2 = (2**10)**2 a=120*1024**3 b=512*1024**2 show(a) show(b) show(a/b) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}128849018880
\newcommand{\Bold}[1]{\mathbf{#1}}536870912
\newcommand{\Bold}[1]{\mathbf{#1}}240
\newcommand{\Bold}[1]{\mathbf{#1}}128849018880
\newcommand{\Bold}[1]{\mathbf{#1}}536870912
\newcommand{\Bold}[1]{\mathbf{#1}}240
#3) kilo=1000 mega=1000**2 giga=1000**3 tera=1000**4 kibi=1024 mebi=1024**2 gibi=1024**3 tibi=1024**4 print "kilo = ", kilo print "mega = ", mega print "giga = ", giga print "tera = ", tera print "kibi = ", kibi print "mebi = ", mebi print "gibi = ", gibi print "tibi = ", tibi 
       
kilo =  1000
mega =  1000000
giga =  1000000000
tera =  1000000000000
kibi =  1024
mebi =  1048576
gibi =  1073741824
tibi =  1099511627776
kilo =  1000
mega =  1000000
giga =  1000000000
tera =  1000000000000
kibi =  1024
mebi =  1048576
gibi =  1073741824
tibi =  1099511627776

#4)

1 bit = {0,1}

2 bits = {00, 01, 10, 11}

3 bits = {000, 001, 010, 011, 100, 101, 110, 111}

8 bits makes 2**8 combinations

#4) print 2**1 print 2**2 print 2**3 print 2**8 print 2**16 
       
2
4
8
256
65536
2
4
8
256
65536
#5) 8 bits is good, but need at least 7 bits 
       
#6) cmp executes 7 times, 1-6 to sum, last to stop 
       
#7) ax=7 counts how many cmp, bx=21 is the sum in base 10