5.3 BIN,OCT,HEX MrG 2013.0124

3226 days ago by CSH2012

#1a) 1111111 base 2 int('1111111',2) 
       
127
127
#1b) 111111111111111 base 2 int('111111111111111',2) 
       
32767
32767
#2) 9 0 A B hex = ??? bin #2) 1001 0000 1010 1011 
       
#3) 010 1110 1011 bin = ??? hex #3) 2 E B 
       
#4) F 0 C 2 hex = ??? bin #4) 1111 0000 1100 0010 #4) ???? bin = ??? oct #4) 1 111 000 011 000 010 bin = ??? oct #4) 1 7 0 3 0 2 show(int('f0c2',16)) show(int('1111000011000010',2)) show(int('170302',8)) show(bin(61634)) show(oct(61634)) show(hex(61634)) show(oct(int('170302',8))) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}61634
\newcommand{\Bold}[1]{\mathbf{#1}}61634
\newcommand{\Bold}[1]{\mathbf{#1}}61634
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{0b1111000011000010}
\newcommand{\Bold}[1]{\mathbf{#1}}170302
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{f0c2}
\newcommand{\Bold}[1]{\mathbf{#1}}0170302
\newcommand{\Bold}[1]{\mathbf{#1}}61634
\newcommand{\Bold}[1]{\mathbf{#1}}61634
\newcommand{\Bold}[1]{\mathbf{#1}}61634
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{0b1111000011000010}
\newcommand{\Bold}[1]{\mathbf{#1}}170302
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{f0c2}
\newcommand{\Bold}[1]{\mathbf{#1}}0170302
#5a) (1011100 bin)(4 dec) = ??? bin #5a) (92 dec)(4 dec) = 368 dec #5a) 1 0 1 1 1 0 0 0 0 #5b) (1011100 bin)/(4 dec) = 10111 bin 92/4 
       
23
23
#6) def countBits(n): 'returns the count of bits in a pos int' count = 0 while n>0: if n%2 != 0: count=count+1 n=n//2 return count countBits(7) 
       
3
3
#7) def intToBin(n): 'returns binary string version on n a positive int' if n==0: return '0' s='' while n>0: if n%2 != 0: s='1'+s else: s='0'+s n=n//2 return s intToBin(10) 
       
'1010'
'1010'
# SIZE MATTERS! show(int('f',16)) show(int('1111',2)) show(2^4-1) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}15
\newcommand{\Bold}[1]{\mathbf{#1}}15
\newcommand{\Bold}[1]{\mathbf{#1}}15
\newcommand{\Bold}[1]{\mathbf{#1}}15
\newcommand{\Bold}[1]{\mathbf{#1}}15
\newcommand{\Bold}[1]{\mathbf{#1}}15
show(int('ff',16)) show(int('11111111',2)) show(2^8-1) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}255
\newcommand{\Bold}[1]{\mathbf{#1}}255
\newcommand{\Bold}[1]{\mathbf{#1}}255
\newcommand{\Bold}[1]{\mathbf{#1}}255
\newcommand{\Bold}[1]{\mathbf{#1}}255
\newcommand{\Bold}[1]{\mathbf{#1}}255
show(int('fff',16)) show(int('111111111111',2)) show(2^12-1) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}4095
\newcommand{\Bold}[1]{\mathbf{#1}}4095
\newcommand{\Bold}[1]{\mathbf{#1}}4095
\newcommand{\Bold}[1]{\mathbf{#1}}4095
\newcommand{\Bold}[1]{\mathbf{#1}}4095
\newcommand{\Bold}[1]{\mathbf{#1}}4095
show(int('ffff',16)) show(int('1111111111111111',2)) show(2^16-1) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}65535
\newcommand{\Bold}[1]{\mathbf{#1}}65535
\newcommand{\Bold}[1]{\mathbf{#1}}65535
\newcommand{\Bold}[1]{\mathbf{#1}}65535
\newcommand{\Bold}[1]{\mathbf{#1}}65535
\newcommand{\Bold}[1]{\mathbf{#1}}65535
show(int('ffffffff',16)) show(int('11111111111111111111111111111111',2)) show(2^32-1) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}4294967295
\newcommand{\Bold}[1]{\mathbf{#1}}4294967295
\newcommand{\Bold}[1]{\mathbf{#1}}4294967295
\newcommand{\Bold}[1]{\mathbf{#1}}4294967295
\newcommand{\Bold}[1]{\mathbf{#1}}4294967295
\newcommand{\Bold}[1]{\mathbf{#1}}4294967295
show(int('ffffffffffffffff',16)) show(int('1111111111111111111111111111111111111111111111111111111111111111',2)) show(2^64-1) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}18446744073709551615
\newcommand{\Bold}[1]{\mathbf{#1}}18446744073709551615
\newcommand{\Bold}[1]{\mathbf{#1}}18446744073709551615
\newcommand{\Bold}[1]{\mathbf{#1}}18446744073709551615
\newcommand{\Bold}[1]{\mathbf{#1}}18446744073709551615
\newcommand{\Bold}[1]{\mathbf{#1}}18446744073709551615
2^64/2 
       
9223372036854775808
9223372036854775808