1 / 34

Numbers & Logic

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

Download Presentation

Numbers & Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Numbers & Logic Bits & Pieces 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 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. 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 Chapter 0

  5. A general exampleBase n • Binary Number 0 1 0 1 • n(place - 1)n3n2n1n0 • =============================== • 0*(n * n* n) + 1*(n*n) + 0* n + 1*1 Chapter 0

  6. Commonly Used Systems • Binary Base 2 • Octal Base 8 • Decimal Base 10 • Hexadecimal Base 16 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 Chapter 0

  8. What is the decimal value of? • 10101 base 2 • 10101 base 8 • 10101 base 10 • 10101 base 16 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 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 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 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 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 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 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 < <= = >= > Chapter 0

  16. Logical Expressions • a logical-expression is any expression that evaluates to False or True • False • True • notlogical-expression • logical-expression and logical-expression • logical-expressionorlogical-expression Chapter 0

  17. Logical Expressionsare not unlikeNumerical 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 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 • + - * / ^ 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. 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 Chapter 0

  21. A 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 Truth Tables 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. Chapter 0

  23. - (unary) * / div mod numerical operators + - < = >= > <= relational operators not and logical operators or Operator Precedence 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 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 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 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 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 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 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 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 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 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 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 Chapter 0

More Related