NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting...
-
Upload
annabelle-mcbride -
Category
Documents
-
view
216 -
download
0
Transcript of NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting...
![Page 1: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/1.jpg)
NUMBER SYSTEM AND COMPUTER CODES
Chapter 2
![Page 2: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/2.jpg)
Prelude
• Fingers, sticks, and other things for counting were not enough!
• Counting large numbers
• Count in groups
Evolution of the number system
![Page 3: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/3.jpg)
Number systems
A set of values used to represent quantity
• Non-Positional Number Systems
• count with their fingers, stones and pebbles
• difficult to perform arithmetic operations
• No zero, difficult to calculate large numbers
• E.g. the Roman number system
• Positional Number Systems
• Finite number of symbols to represent any numbers
• Symbol and it’s position defines a number
• Decimal, binary, octal, hexadecimal
![Page 4: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/4.jpg)
ASCII- American standard for Information Interchange
![Page 5: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/5.jpg)
Base or radix
• Number of unique digits
![Page 6: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/6.jpg)
6
Number Systems - Decimal
• The decimal system is a base-10 system.
• There are 10 distinct digits (0 to 9) to represent any quantity.
• For an n-digit number, the value that each digit represents depends on its weight or position.
• The weights are based on powers of 10.
1024 = 1*103 + 0*102 + 2*101 + 4*100
= 1000 + 20 + 4
![Page 7: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/7.jpg)
7
Number Systems - Binary
• The binary system is a base-2 system.
• There are 2 distinct digits (0 and 1) to represent any quantity.
• For an n-digit number, the value of a digit in each column depends on its position.
• The weights are based on powers of 2.
10112 = 1*23 + 0*22 + 1*21 + 1*20
=8+2+1 =1110
![Page 8: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/8.jpg)
8
Number Systems - Octal
• Octal and hexadecimal systems provide a shorthand way to deal with the long strings of 1’s and 0’s in binary.
• Octal is base-8 system using the digits 0 to 7.
• To convert to decimal, you can again use a column weighted system
• 75128 = 7*83 + 5*82 + 1*81 + 2*80 = 391410
• An octal number can easily be converted to binary by replacing each octal digit with the corresponding group of 3 binary digits 75128 = 1111010010102
![Page 9: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/9.jpg)
9
Number Systems - Hexadecimal
• Hexadecimal is a base-16 system.
• It contains the digits 0 to 9 and the letters A to F (16 digit values).
• The letters A to F represent the unit values 10 to 15.
• This system is often used in programming as a condensed form for binary numbers (0x00FF, 00FFh)
• To convert to decimal, use a weighted system with powers of 16.
![Page 10: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/10.jpg)
10
Example- Value of 2001 in Binary, Octal and Hexadecimal
![Page 11: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/11.jpg)
11
Example- Conversion: Binary Octal Hexadecimal
![Page 12: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/12.jpg)
12
Converting decimal to binary, octal and hexadecimal
• To convert from decimal to a different number base such as Octal, Binary or Hexadecimal involves repeated division by that number base
• Keep dividing until the quotient is zero
• Use the remainders in reverse order as the digits of the converted number
Repeated Divide by 2
![Page 13: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/13.jpg)
CPE1002 (c) Monash University 13
BaseN to Decimal Conversions Multiply each digit by increasing powers of the
base value and add the terms Example: 101102 = ??? (decimal)
04/03/10
![Page 14: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/14.jpg)
Binary Addition
• Similar to decimal operation
• Leading zeroes are frequently dropped.
4 Possible Binary Addition Combinations:
(1) 0 (2) 0
+0 +1
00 01
(3) 1 (4) 1
+0 +1
01 10
SumCarry
Ex 1,2,3
For Exam
![Page 15: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/15.jpg)
Binary Subtraction
Just like subtraction in any other baseMinuend 10110Subtrahend - 10010Difference 00100
And when a borrow is needed. Note that the borrow gives us 2 in the current bit position.
Ex 1,2
For Exam
![Page 16: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/16.jpg)
And a full example
And more ripple -
![Page 17: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/17.jpg)
17
Octal/Hex addition/subtractionOctal Addition 1 1 1 Carries 5 4 7 1 Augends + 3 7 5 4 Addend 11445 Sum
Octal Subtraction
6 10 4 10 Borrows 7 4 5 1 Minuend - 5 6 4 3 Subtrahend 1 6 0 6 Difference
Hexadecimal Addition
1 0 1 1 Carries 5 B A 9 Augend + D 0 5 8 Addend 1 2 C 0 1 Sum
Hexadecimal Subtraction
9 10 A 10 Borrows A 5 B 9 Minuend + 5 8 0 D Subtrahend 4 D A C Difference
![Page 18: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/18.jpg)
BCD
Binary-coded decimal, or BCD, is a method of using binary digits to represent the decimal digits 0 through 9. A decimal digit is represented by four binary digits …
The binary combinations 1010 to 1111 are invalid and are not used.
![Page 19: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/19.jpg)
ASCII Code
"ask-key“- common code for microcomputer
Standard ASCII character set
• 128 decimal numbers ranging (0-127)
• Assigned to letters, numbers, punctuation marks, and the most common special characters.
The Extended ASCII Character Set
• also consists of 128 decimal numbers (128-255)
• representing additional special, mathematical, graphic, and foreign characters.
Groups of 32 characters
![Page 20: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/20.jpg)
EBCDIC - Extended Binary Coded Decimal Interchange Code
• It is an 8 bit character encoding
• Used on IBM mainframes and AS/400s.
• It is descended from punched cards
• The first four bits are called the zone
• category of the character
• Last four bits are the called the digit
• identify the specific character
There are a number of different versions of EBCDIC, customized for different countries.
![Page 21: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/21.jpg)
AssignmentsIOA, IA, GA, Case !@#$
![Page 22: NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.](https://reader036.fdocuments.us/reader036/viewer/2022062517/56649e925503460f94b978e5/html5/thumbnails/22.jpg)
Chapter 1 22
BinaryMultiplication
Division
1 1 0 1 0 Multiplicand x 1 0 1 0 Multiplier 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 0 1 0
1 0 0 0 0 0 1 0 0 Product
1 0 0 1 1 1 1 1 0 11 0 0 1
1 1 0 01 0 0 1
1 1 1
1 1 0 QuotientDividend
Remainder
Divider