base conversions convert 123| 10 to base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | |...

54
Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10 = 20 `------- 1 x 10 2 = 1 x 100 = 100 123 Therefore, 123| 10 = 123| 10

Upload: amberly-ross

Post on 13-Jan-2016

245 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert 123|10 to Base 10 (gotta start someplace)

1 2 3 |10 = ? |10

| | |

| | `--- 3 x 100 = 3 x 1 = 3

| `----- 2 x 101 = 2 x 10 = 20

`------- 1 x 102 = 1 x 100 = 100

123

Therefore, 123|10 = 123|10

Page 2: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert 123|8 to Base 10

1 2 3 |8 = ? |10

| | |

| | `--- 3 x 80 = 3 x 1 = 3

| `----- 2 x 81 = 2 x 8 = 16

`------- 1 x 82 = 1 x 64 = 64

83

Therefore, 123|8 = 83|10

Page 3: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert 2BAD|16 to Base 10

2 B A D |16 = ? |10

| | | |

| | | `--- D x 160 = 13 x 1 = 13

| | `----- A x 161 = 10 x 16 = 160

| `------- B x 162 = 11 x 256 = 2816

`--------- 2 x 163 = 2 x 4096 = 8192

11181

Therefore, 2BAD|16 = 11181|10

Page 4: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert 20DD|16 to Base 10

??

Page 5: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert 20DD|16 to Base 10

2 0 D D |16 = ? |10

| | | |

| | | `--- D x 160 = 13 x 1 = 13

| | `----- D x 161 = 13 x 16 = 208

| `------- 0 x 162 = 0 x 256 = 0

`--------- 2 x 163 = 2 x 4096 = 8192

8413

Therefore, 20DD|16 = 8413|10

Page 6: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert FACE|16 to Base 10

??

Page 7: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base ConversionsConvert FACE|16 to Base 10

F A C E |16 = ? |10

| | | |

| | | `--- E x 160 = 14 x 1 = 14

| | `----- C x 161 = 12 x 16 = 192

| `------- A x 162 = 10 x 256 = 2560

`--------- F x 163 = 15 x 4096 = 61440

64206

Therefore, FACE|16 = 64206|10

Page 8: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Convert 123|10 to Base 8

8 )123

8 )15 R 3

8 )1 R 7

0 R 1

Therefore, 123|10 = 173|8

Base Conversions

Base you are converting to

Read Up!

Page 9: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Read Up!

Convert 64206|10 to Base 16

16 )64206

16 )4012 R 14 (E)

16 )250 R 12 (C)

16 )15 R 10 (A)

16 )0 R 15 (F)

Therefore, 64206|10 = FACE|16

Base Conversions

Base you are converting to

Page 10: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Step 1: 123|7=?|10

1 2 3

| | |

| | `-3x70= 3

| `--2x71=14

`-----1x72=49

66

123|7=66|10

Step 2: 66|10=?|9

9 )66

9 ) 7 R 3

0 R 7 66|10=73|9

123|7=73|9

Base Conversions123|7 = ?|9 (Can’t do directly)

Page 11: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Base Conversions• Converting between

bases which are powers of 2 (base 2, 4, 8, and 16)

• Each Digit in base 4, 8 or 16 represents 2, 3 or 4 bits

Dec Bin Base 4 Octal Hex

0 0000 00 00 0

1 0001 01 01 1

2 0010 02 02 2

3 0011 03 03 3

4 0100 10 04 4

5 0101 11 05 5

6 0110 12 06 6

7 0111 13 07 7

8 1000 20 10 8

9 1001 21 11 9

10 1010 22 12 A

11 1011 23 13 B

12 1100 30 14 C

13 1101 31 15 D

14 1110 32 16 E

15 1111 33 17 F

Page 12: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

10101110001101|2=?|8

#10 101 110 001 101

2 5 6 1 5

10101110001101|2=25615|8

NOTE: # is a place holder for zero

Base ConversionsDec Bin Bs 4 Oct Hex

0 0000 00 00 0

1 0001 01 01 1

2 0010 02 02 2

3 0011 03 03 3

4 0100 10 04 4

5 0101 11 05 5

6 0110 12 06 6

7 0111 13 07 7

8 1000 20 10 8

9 1001 21 11 9

10 1010 22 12 A

11 1011 23 13 B

12 1100 30 14 C

13 1101 31 15 D

14 1110 32 16 E

15 1111 33 17 F

Work from right to left Divide into 3 bit groups

Page 13: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

10101110001101|2=?|16

##10 1011 1000 1101

2 B 8 D

10101110001101|2=2B8D|16

NOTE: # is a place holder for zero

Base ConversionsDec Bin Bs 4 Oct Hex

0 0000 00 00 0

1 0001 01 01 1

2 0010 02 02 2

3 0011 03 03 3

4 0100 10 04 4

5 0101 11 05 5

6 0110 12 06 6

7 0111 13 07 7

8 1000 20 10 8

9 1001 21 11 9

10 1010 22 12 A

11 1011 23 13 B

12 1100 30 14 C

13 1101 31 15 D

14 1110 32 16 E

15 1111 33 17 F

Work from right to left Divide into 4 bit groups

Page 14: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

1357|8=?|2

1 3 5 7

001 011 101 111

|8=001011101111|2

Base ConversionsDec Bin Bs 4 Oct Hex

0 0000 00 00 0

1 0001 01 01 1

2 0010 02 02 2

3 0011 03 03 3

4 0100 10 04 4

5 0101 11 05 5

6 0110 12 06 6

7 0111 13 07 7

8 1000 20 10 8

9 1001 21 11 9

10 1010 22 12 A

11 1011 23 13 B

12 1100 30 14 C

13 1101 31 15 D

14 1110 32 16 E

15 1111 33 17 F

Note: one need not write the leading zeros

Page 15: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

FACE|16=?|2

F A C E

1111 1010 1100 1110

FACE|16=1111101011001110|2

Base ConversionsDec Bin Bs 4 Oct Hex

0 0000 00 00 0

1 0001 01 01 1

2 0010 02 02 2

3 0011 03 03 3

4 0100 10 04 4

5 0101 11 05 5

6 0110 12 06 6

7 0111 13 07 7

8 1000 20 10 8

9 1001 21 11 9

10 1010 22 12 A

11 1011 23 13 B

12 1100 30 14 C

13 1101 31 15 D

14 1110 32 16 E

15 1111 33 17 F

Page 16: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

A1CE|16=?|8

2 1 C E

1010000111001110

1 2 0 7 1 6

A1CE|16=120716|8

Base ConversionsDec Bin Bs 4 Oct Hex

0 0000 00 00 0

1 0001 01 01 1

2 0010 02 02 2

3 0011 03 03 3

4 0100 10 04 4

5 0101 11 05 5

6 0110 12 06 6

7 0111 13 07 7

8 1000 20 10 8

9 1001 21 11 9

10 1010 22 12 A

11 1011 23 13 B

12 1100 30 14 C

13 1101 31 15 D

14 1110 32 16 E

15 1111 33 17 F

Page 17: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Terminology

• Bit – a 0 or a 1

• Nibble – 4 bits

• Byte – 8 bits

• Word – Machine dependent(8086/88 = 16 bits; 386/486/Pent = 32 bits)

• Doubleword – Machine dependent(8086/88 = 32 bits; 386/486/Pent = 64 bits)

Page 18: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Terminology

• K – Kilo; 210 = 1,024• M – Mega; 220 = 1,048,576• G – Giga; 230 = 1,073,741,824• T – Tera; 240 = 1,099,511,627,776• P – Penta; 250 = 1,125,899,906,842,624• E – Exa; 260 = 1,152,921,504,606,846,976

Page 19: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Rough Cost for RAM/DiskR A M

1956 1978 1985 2000 2004K $19.00 $ 0.16

M $19000. $160.00 $ .50 $ .20

G $500.00 $200.00

T

D i s kK

M $9999.99 $250 $7.00

G $7000.00 $10.00 $ .83

T $9999.99 $830.00

See http://www.littletechshoppe.com/ns1625/winchest.html for more info

Page 20: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

ASCII-American Standard Code for Information Interchange

• Used to represent characters

• Seven bit code used to represent character

• ‘0’ through ‘9’ are characters

• IBM used 8 bits in PC and added 128 additional characters (line drawing, Greek)

• Problem with ASCII – the A

• Unicode addresses this problem

Page 21: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

0 00 C-@ 32 20 64 40 @ 96 60 `1 01 C-A 33 21 ! 65 41 A 97 61 a2 02 C-B 34 22 " 66 42 B 98 62 b3 03 C-C 35 23 # 67 43 C 99 63 c4 04 C-D 36 24 $ 68 44 D 100 64 d5 05 C-E 37 25 % 69 45 E 101 65 e6 06 C-F 38 26 & 70 46 F 102 66 f7 07 C-G 39 27 ' 71 47 G 103 67 g8 08 C-H 40 28 ( 72 48 H 104 68 h9 09 C-I 41 29 ) 73 49 I 105 69 i

10 0A C-J 42 2A * 74 4A J 106 6A j11 0B C-K 43 2B + 75 4B K 107 6B k12 0C C-L 44 2C , 76 4C L 108 6C l13 0D C-M 45 2D - 77 4D M 109 6D m14 0E C-N 46 2E . 78 4E N 110 6E n15 0F C-O 47 2F / 79 4F O 111 6F o16 10 C-P 48 30 0 80 50 P 112 70 p17 11 C-Q 49 31 1 81 51 Q 113 71 q18 12 C-R 50 32 2 82 52 R 114 72 r19 13 C-S 51 33 3 83 53 S 115 73 s20 14 C-T 52 34 4 84 54 T 116 74 t21 15 C-U 53 35 5 85 55 U 117 75 u22 16 C-V 54 36 6 86 56 V 118 76 v23 17 C-W 55 37 7 87 57 W 119 77 w24 18 C-X 56 38 8 88 58 X 120 78 x25 19 C-Y 57 39 9 89 59 Y 121 79 y26 1A C-Z 58 3A : 90 5A Z 122 7A z27 1B ESC 59 3B ; 91 5B [ 123 7B {28 1C 60 3C < 92 5C \ 124 7C |29 1D 61 3D = 93 5D ] 125 7D }30 1E 62 3E > 94 5E ^ 126 7E ~31 1F 63 3F ? 95 5F _ 127 7F DEL

ASCII-points to note•Values 30-39=Chars ‘0’-’9’

•‘a’ = ‘A’ + 32 (Bit 5)

•‘A’ = Ctrl/A+64 (bit 6)

•‘A’ < ‘Z’ < ‘a’ < ‘z’

•If character is represented in a byte, bit 7 is usually 0

•Chars 0-31d are not printable, but may influence how other chars are printed.

Page 22: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

0000

000

001

0001

000

011

0010

000

101

0011

000

111

0100

001

001

0101

001

011

0110

001

101

0111

001

111

1000

010

001

1001

010

011

1010

010

101

1011

010

111

1100

011

001

1101

011

011

1110

011

101

1111

011

111

000

001

010

011

100

101

110

111

lower 5 bits

uppe

r 3

bits

Page 23: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Binary Addition

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 0 (with carry of 1)

Page 24: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

1011011 + 10110 = ?

1 0 1 1 0 1 1+ 1 0 1 1 0---------------- 1 1 1 0 0 0 1

Page 25: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

100111001 + 11011 = ?

1 0 0 1 1 1 0 0 1+ 1 1 0 1 1 -----------------

Page 26: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

100111001 + 11011 = ?

1 0 0 1 1 1 0 0 1+ 1 1 0 1 1 ----------------- 1 0 1 0 1 0 1 0 0

Page 27: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Two possible values- TRUE represented by non-zero - FALSE represented by zero

Logical Operations

i.e. 5 is TRUE5.32 is TRUE'T' is TRUE'F' is TRUE-45 is TRUE

0 is FALSE

Page 28: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

FALSE && FALSE is FALSEFALSE && TRUE is FALSETRUE && FALSE is FALSETRUE && TRUE is TRUE

5 && 0 is FALSE (zero)4 && 'F' is TRUE (non-zero)'F' && 'F' is TRUE (non-zero)0 && 'T' is FALSE (zero)0 && 0 is FALSE (zero)

Logical Operations AND &&

Page 29: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

FALSE | | FALSE is FALSEFALSE | | TRUE is TRUETRUE | | FALSE is TRUETRUE | | TRUE is TRUE

5 | | 0 is TRUE (non-zero)4 | | 'F' is TRUE (non-zero)'F' | | 'F' is TRUE (non-zero)0 | | 'T' is TRUE (non-zero) 0 | | 0 is FALSE (zero)

Logical Operations OR | |

Page 30: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

FALSE ^^ FALSE is FALSEFALSE ^^ TRUE is TRUETRUE ^^ FALSE is TRUETRUE ^^ TRUE is FALSE

5 ^^ 0 is TRUE (non-zero)4 ^^ 'F' is FALSE (zero) 'F' ^^ 'F' is FALSE (zero) 0 ^^ 'T' is TRUE (non-zero) 0 ^^ 0 is FALSE (zero)

Logical Operations XOR ^^

Page 31: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

! FALSE is TRUE! TRUE is FALSE

!0 is TRUE (non-zero)!4 is FALSE (zero) !'F' is FALSE (zero) !!0 is FALSE (zero)!!52 is TRUE (non-zero)

Logical Operations NOT !

Page 32: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Logical Operations Summary

A !A

FALSE TRUE

TRUE FALSE

A B A&&B

FALSE FALSE FALSE

FALSE TRUE FALSE

TRUE FALSE FALSE

TRUE TRUE TRUE

Page 33: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Logical Operations Summary

A B A ^^ B

FALSE FALSE FALSE

FALSE TRUE TRUE

TRUE FALSE TRUE

TRUE TRUE FALSE

A B A | | B

FALSE FALSE FALSE

FALSE TRUE TRUE

TRUE FALSE TRUE

TRUE TRUE TRUE

Page 34: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Logical Operations Summary

A B !A A&&B A | | B A ^^ B

FALSE FALSE TRUE FALSE FALSE FALSE

FALSE TRUE TRUE FALSE TRUE TRUE

TRUE FALSE FALSE FALSE TRUE TRUE

TRUE TRUE FALSE TRUE TRUE FALSE

Page 35: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

• Deal with individual bits of a value

• Each bit is evaluated separatly

• There is no "Carry" as with addition…i.e. the results of an operation in one bit position has no effect on an adjacent bit.

• Uses similar notation to Logical operators &=AND, |=OR, ^=XOR

• However ~ bitwise NOT (COMPLIMENT)

Page 36: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

A ~ A

0 1

1 0

A B A&B

0 0 0

0 1 0

1 0 0

1 1 1

A B A|B

0 0 0

0 1 1

1 0 1

1 1 1

A B A^B

0 0 0

0 1 1

1 0 1

1 1 0

AND

XOR (exclusive or)OR

NOT

Page 37: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10111001 & 11110000 = ?

1 0 1 1 1 0 0 11 1 1 1 0 0 0 0---------------1 0 1 1 0 0 0 0

A B A&B

0 0 0

0 1 0

1 0 0

1 1 1

Page 38: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10101010 & 11110000 = ?

1 0 1 0 1 0 1 01 1 1 1 0 0 0 0---------------

A B A&B

0 0 0

0 1 0

1 0 0

1 1 1

Page 39: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10101010 & 11110000 = ?

1 0 1 0 1 0 1 01 1 1 1 0 0 0 0---------------1 0 1 0 0 0 0 0

A B A&B

0 0 0

0 1 0

1 0 0

1 1 1

Page 40: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10111001 | 11110000 = ?

1 0 1 1 1 0 0 11 1 1 1 0 0 0 0---------------1 1 1 1 1 0 0 1

A B A | B

0 0 0

0 1 1

1 0 1

1 1 1

Page 41: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10101010 | 11110000 = ?

1 0 1 0 1 0 1 01 1 1 1 0 0 0 0---------------

A B A | B

0 0 0

0 1 1

1 0 1

1 1 1

Page 42: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10101010 | 11110000 = ?

1 0 1 0 1 0 1 01 1 1 1 0 0 0 0---------------1 1 1 1 1 0 1 0

A B A | B

0 0 0

0 1 1

1 0 1

1 1 1

Page 43: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10111001 ^ 11110000 = ?

1 0 1 1 1 0 0 11 1 1 1 0 0 0 0---------------0 1 0 0 1 0 0 1

A B A ^ B

0 0 0

0 1 1

1 0 1

1 1 0

Page 44: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10101010 ^ 11110000 = ?

1 0 1 0 1 0 1 01 1 1 1 0 0 0 0---------------

A B A ^ B

0 0 0

0 1 1

1 0 1

1 1 0

Page 45: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical Operations

10101010 ^ 11110000 = ?

1 0 1 0 1 0 1 01 1 1 1 0 0 0 0---------------0 1 0 1 1 0 1 0

A B A ^ B

0 0 0

0 1 1

1 0 1

1 1 0

Page 46: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Bitwise Logical OperationsABCD | FF00 & 5555 1111 1111 0000 0000

0101 0101 0101 0101-------------------

5500 0101 0101 0000 0000

0101 0101 0000 00001010 1011 1100 1101-------------------

FFCD 1111 1111 1100 1101

NOTE: & is a higher precedence than |

similar to * being a higher precedence than + in algebra.

A B A&B A|B A^B

0 0 0 0 0

0 1 0 1 1

1 0 0 1 1

1 1 1 1 0

Page 47: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Hex Addition

4BA978

+ D2B84

58D4FC

• 8+4=C• 7+8=F• 9+B=4 w/ carry• 1+A+2=D• B+D=8 w/ carry• 1+4+0=5

Page 48: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Hex Addition Table

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10

00 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 1001 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 1102 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 1203 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 1304 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 1405 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 1506 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 1607 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 1708 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 1809 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 190A 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A0B 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B0C 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C0D 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D0E 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E0F 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F10 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20

Page 49: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Positive/Negative Numbers

Notes• We are in “4-bit” mode• Think odometer math (-1=1111, -2=1110,

-3=1101, -4=1100, -5=1011, -6=1010, etc.)• At some point a big positive number+1

becomes a big negative number• Really a number “circle”

00000001

00100011

010001011011

1100 111011111101

0 1 2 3 4 5-5 -4 -2 -1-3

Page 50: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

4-bit Number Circle0000

0001

0010

0011

0100

01011011

1100

1110

1111

1101

1010

1001 1000 0111

0110

01

2

3

4

5-5

-4

-2

-1

-3

67

-8-7

-6

Page 51: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Observations (Part 1)

0110 6+ 0011 + 31001 9

1010 -61101 +-3

10001 9

0100 40010 + 20110 6

1100 -41110 +-2

11010 -6

0110 61101 +-3

10011 3

1010 -60011 + 31101 -3

Page 52: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Observations (Part 2)

0110 6+ 0011 + 31001 9

1010 -61101 +-3

10001 9

0100 40010 + 20110 6

1100 -41110 +-2

11010 -6

0110 61101 +-3

10011 3

1010 -60011 + 31101 -3

Page 53: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Observations (Part 3) & Conclusions• Note when a carry into the sign bit occurs

• Note when a carry out of the sign bit occurs

• If one occurs and not the other – WRONG

• If both occur – RIGHT

• If neither occur – RIGHT

• Therefore:

OF = carry into sign bit carry out of sign bit

Page 54: Base Conversions Convert 123| 10 to Base 10 (gotta start someplace) 1 2 3 | 10 = ? | 10 | | | | | `--- 3 x 10 0 = 3 x 1 = 3 | `----- 2 x 10 1 = 2 x 10

Organization of a computer

CPU RAM ROM Printer Disk CRT Kbd

Address Bus

Data Bus

Control Bus