numbers & logic
DESCRIPTION
Numbers & Logic. Bits & Pieces. Base 10 example. Decimal Number 9 7 0 1 Place 4 3 2 1 Place - 1 3 2 1 0 10 (place - 1) 10 3 10 2 10 1 10 0 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/1.jpg)
Chapter 0 1
Numbers & Logic
Bits & Pieces
![Page 2: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/2.jpg)
Chapter 0 2
Base 10 example
• Decimal Number 9 7 0 1
• Place 4 3 2 1
• Place - 1 3 2 1 0
• 10(place - 1) 103 102 101 100
• =============================== • = 9*1000 + 7*100 + 0*10 + 1*1
• = 9701
![Page 3: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/3.jpg)
Chapter 0 3
Numeric Values– The numeric value of a set of digits is
determined as:• The sum of the products of each digit and its
corresponding place value,
• where the place value is the numeric-base raised to the place - 1.
![Page 4: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/4.jpg)
Chapter 0 4
Base 2 example
• Binary Number 0 1 0 1
• 2(place - 1) 23 22 21 20
• ===============================
• = 0*8 + 1*4 + 0*2 + 1*1
• = 5
![Page 5: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/5.jpg)
Chapter 0 5
A general exampleBase n
• Binary Number 0 1 0 1
• n(place - 1) n3 n2 n1 n0
• ===============================
• 0*(n * n* n) + 1*(n*n) + 0* n + 1*1
![Page 6: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/6.jpg)
Chapter 0 6
Commonly Used Systems
• Binary Base 2
• Octal Base 8
• Decimal Base 10
• Hexadecimal Base 16
![Page 7: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/7.jpg)
Chapter 0 7
Legal Digits
• What are the legal digits?
• Start at zero and stop at the base - 1
• Binary 0, 1
• Octal 0, 1, 2, 3, 4, 5, 6, 7
• Decimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Hex 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
![Page 8: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/8.jpg)
Chapter 0 8
What is the decimal value of?
• 10101 base 2
• 10101 base 8
• 10101 base 10
• 10101 base 16
![Page 9: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/9.jpg)
Chapter 0 9
• 0000 00 00 0
• 0001 01 01 1
• 0010 02 02 2
• 0011 03 03 3
• 0100 04 04 4
• 0101 05 05 5
• 0110 06 06 6
• 0111 07 07 7
• 1000 10 08 8
• 1001 11 09 9
• 1010 12 10 A
• 1011 13 11 B
• 1100 14 12 C
• 1101 15 13 D
• 1110 16 14 E
• 1111 17 15 F
• Counting in Binary, Octal, Decimal and Hexadecimal
• A single Hex digit can be used to represent the value of four binary digits
![Page 10: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/10.jpg)
Chapter 0 10
Hex = Binary Shorthand
• Hexadecimals are often used as a shorthand for large binary values.
• This shorthand is useful for specifying memory locations, e.g.
• Decimal - 16,274,482
• Binary - 111110000101010000110010
• Hex - F85432
![Page 11: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/11.jpg)
Chapter 0 11
Binary to Hex
• Each Hexadecimal digit represents four binary digits
• 1111 1000 0101 0100 0011 0010
• F 8 5 4 3 2
![Page 12: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/12.jpg)
Chapter 0 12
Binary to Octal
• Each Octal digit represents three binary digits
• 111 110 000 101 010 000 110 010
• 7 6 0 5 2 0 6 2
![Page 13: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/13.jpg)
Chapter 0 13
ASCII & EBCDIC
• American Standard Code for Information Interchange– ASCII @ Wikipedia
• Binary Coded Decimals– Binary Coded Decimals
• Extended Binary Coded Decimals– EBCDIC @ Wikipedia
• Unicode– Unicode @ Wikipeda
![Page 14: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/14.jpg)
Chapter 0 14
Boolean Logic
• A two valued logic often used in computers and information systems.
• The only legal values in Boolean Logic are– TRUE– FALSE
![Page 15: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/15.jpg)
Chapter 0 15
Logical Values
• Logical values can only be True or False
• Similar to numeric values, logical values can be combined into logical expressions using logical operators.
• The logical operators are: not and or < <= = >= >
![Page 16: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/16.jpg)
Chapter 0 16
Logical Expressions
• a logical-expression is any expression that evaluates to False or True
• False
• True• not logical-expression
• logical-expression and logical-expression
• logical-expression or logical-expression
![Page 17: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/17.jpg)
Chapter 0 17
Logical Expressionsare not unlike
Numerical Expressions• A numerical-expression is any expression that
evaluates to a legal numerical value.
• Examples of numerical expressions:– 3– -4– 3 + 8 / 2– (3 + 8) / 2
![Page 18: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/18.jpg)
Chapter 0 18
Numerical Operators
• Unary operators have only one argument– the positive and negative signs are the unary
numerical operators.– + -
• Binary operators require two arguments– addition, subtraction, multiplication, division,
and exponentiation are the binary operators– + - * / ^
![Page 19: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/19.jpg)
Chapter 0 19
You’ve probably already used logical expressions
• The relational operators > >= = < <= evaluate to logical results.
• Example– the expression 3 + 5 <= 8 - 4 evaluates to a
value of False, so it is a logical expression.– Note that here we have combined numerical
expressions with relational operators to form a logical expression.
![Page 20: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/20.jpg)
Chapter 0 20
Logical Operators
• Unary operators have only one argument– not is the only unary logical operator.– not
• Binary operators require two arguments– conjunction and disjunction are the binary
operators – and or
![Page 21: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/21.jpg)
Chapter 0 21
Truth TablesA NOT A
F T
T F
A B A AND B
F F F
F T F
T F F
T T T
A B A OR B
F F F
F T T
T F T
T T T
![Page 22: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/22.jpg)
Chapter 0 22
Operator Precedence
• Higher precedence evaluate first,• Equal precedence evaluate left to right• Parenthesis can be used to modify the order of precedence, expressions inside parenthesis are evaluated first.
![Page 23: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/23.jpg)
Chapter 0 23
Operator Precedence
- (unary)
* / div mod numerical operators
+ -
< = >= > <= relational operators
not
and logical operators
or
![Page 24: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/24.jpg)
Chapter 0 24
Evaluation of Logical Expressions
• A = True
• B = False
• Given the above evaluate the following:
• A or B => True
• A and B => False
• 3 > 7 or A => TRUE
• (3 < 7) and not A => False
![Page 25: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/25.jpg)
Chapter 0 25
Complex Logical Expression
• A = True B = False C = True D =False
• A or not B and not (3 + 7 <= 10 / 2) or C and D
![Page 26: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/26.jpg)
Chapter 0 26
Complex Logical Expression
• A = True B = False C = True D =False
• A or not B and not (3 + 7 <= 10 / 2) or C and D
• T or not F and not (3 + 7 <= 10 / 2) or T and F
![Page 27: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/27.jpg)
Chapter 0 27
Complex Logical Expression
• A = True B = False C = True D =False
• A or not B and not (3 + 7 <= 10 / 2) or C and D
• T or not F and not (3 + 7 <= 10 / 2) or T and F
• T or not F and not ( 10 <= 5 ) or T and F
• T or not F and not ( F ) or T and F
![Page 28: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/28.jpg)
Chapter 0 28
Complex Logical Expression
• A = True B = False C = True D =False
• A or not B and not (3 + 7 <= 10 / 2) or C and D
• T or not F and not ( F ) or T and F
• T or T and T or T and F
![Page 29: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/29.jpg)
Chapter 0 29
Complex Logical Expression
• A = True B = False C = True D =False
• A or not B and not (3 + 7 <= 10 / 2) or C and D
• T or T and T or T and F
• T or T or F
![Page 30: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/30.jpg)
Chapter 0 30
Complex Logical Expression
• A = True B = False C = True D =False
• A or not B and not (3 + 7 <= 10 / 2) or C and D
• T or T or F
• T or F
• T
![Page 31: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/31.jpg)
Chapter 0 31
Normal Forms
• Conjunctive Normal Form– A and B and C and D and E– any false value makes the expression false
• Disjunctive Normal Form– A or B or C or D or E– any true value makes the expression true
![Page 32: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/32.jpg)
Chapter 0 32
Computer Time
• millisecond 10-3 = 1/1,000
• microsecond 10-6 = 1/1,000,000
• nanosecond 10-9 = 1/1,000,000,000
• picosecond 10-12 = 1/1,000,000,000,000
• femtosecond 10-15 = 1/1,000,000,000,000,000
• Conversion of Time Units
![Page 33: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/33.jpg)
Chapter 0 33
Computer Units
• Thousand 103 = 1,000• Kilobyte 210 = 1,024• Million 106 = 1,000,000• Megabyte 220 = 1,048,576• Billion 109 = 1,000,000,000• Gigabyte 230 = 1,073,741,824• Trillion 1012 = 1,000,000,000,000• Terabyte 240 = 1,099,511,627,776
![Page 34: Numbers & Logic](https://reader036.vdocuments.us/reader036/viewer/2022062321/568134ef550346895d9c2bb9/html5/thumbnails/34.jpg)
Chapter 0 34
Bigger Units• Trillion 1012 = 1,000,000,000,000• Terabyte 240 = 1,099,511,627,776• Quadrillion 1015 = 1,000,000,000,000,000• Petabyte 250 = 1,125,899,906,842,624• Quintillion 1018 = 1,000,000,000,000,000,000• Exabyte 260 = 1,152,921,504,606,846,976• Sextillion 1021 = 1,000,000,000,000,000,000,000• Zettabyte 270 = 1,180,591,620,717,411,303,424• Septillion 1024 = 1,000,000,000,000,000,000,000,000• Yottabyte 280 = 1,208,925,819,614,629,174,706,176• Byte Converter – File Size Calculator• Million, Billion, Trillion