tdde25
play

TDDE25 Integer F 2 Natural Chap 1: Data Storage Types of Numbers - PowerPoint PPT Presentation

Types of Numbers What is a number? Complex Russian Dolls Model Real Rational TDDE25 Integer F 2 Natural Chap 1: Data Storage Types of Numbers Number Systems Representation in Computers https://www.ida.liu.se/~TDDE25/index.en.shtml


  1. Types of Numbers What is a number? Complex Russian Dolls Model Real Rational TDDE25 Integer Fö 2 Natural Chap 1: Data Storage Types of Numbers Number Systems Representation in Computers https://www.ida.liu.se/~TDDE25/index.en.shtml Z Q R C N https://liuonline.sharepoint.com/sites/Lisam_TDDE25_2020HT_FZ N ine Z ulu Q ueens R uled C hina 1 2 Natural Numbers Integers Z N • Addition - Closed • Addition - Closed • Multiplication - Closed • Multiplication - Closed Counting Numbers • Subtraction - Not Closed • Subtraction - Closed • Division - Not Closed • Division - Not Closed Solving the Subtraction Problem: • Discovery of zero (600 CE) • Discovery of negative numbers Solving the Division Problem: • Han Dynasty 220 BCE - 202 CE • Discovery of rational numbers • Europe: 17th century CE - Common era • Ratios between two integers 3 4

  2. Rational Numbers Decimal Representation of Fractions Rational numbers are simple quantities: Q • They can be understood in finite terms; • Yet they can be used to represent quantities as small or as large as we please • Addition - Closed Numerator • Multiplication - Closed Denominator • Subtraction - Closed Numerator, Denominator are integers The denominator can not be 0 • Division - Closed Decimal Representation 1 3 = 0 . 333333333 . . . , 29 12 = 2 . 416666666 . . . , Fractions are ultimately periodic: Rational numbers are dense. Between any after a certain point the infinite 9 7 = 1 . 285714285714285 . . . , sequence of digits consists of some two of them, you can always find another! finite sequence of digits repeated • Between 0 and 1 there an infinite number of rationals! 237 148 = 1 . 60135135135 . . . indefinitely! 5 6 Real Numbers Are the Rational Numbers Adequate? Q R Since the rationals are dense, do we need any other quantity Real Numbers = Rational Numbers + Irrational Numbers or can we even fit anything more on the number line? An irrational number is any number that can not be a 2 + b 2 expressed as a ratio a/b where a and b are integers and b is not equal to 0 c 2 = What is the length of the diagonal of the unit square? 1 2 + 1 2 √ = 2 = 1 . 4142135623730950488016887 . . . ? = 1 + 1 = 2 Recall : In decimal notation a rational number is any number that can be represented as terminating or eventually repeating decimals. (Ultimately Periodic) c 2 = 2 Can not be expressed as In decimal notation an irrational number is any number that can not be √ c = 2 the ratio of two integers! represented as terminating or or eventually repeating decimals. (Not Ultimately Periodic) It is an irrational number! 7 8

  3. Countability Some Special Real Numbers Some important irrational numbers in engineering! Q Dense π = C R Continuous d � � π = 3 . 141592653589793238462643383279 . . . ∞ →∞ e ln( x ) = x Are some infinite sets bigger than others? ℕ ⊆ ℚ ⊂ ℝ ln( e x ) = x Euler’s number e = 2 . 7182818284590452353602874713526 . . . Q R e = 1 + 1 1 1 1 1 + 1 × 2 + 1 × 2 × 3 + 1 × 2 × 3 × 4 + · · · × × Countable Uncountable � 1 + 1 � n e = lim n →∞ Infinite Process! n Continuum Hypothesis (Cantor) - There is no set whose cardinality is strictly between that of the (positive) integers and that of the real numbers. Since they are important numbers, we will want to represent them in a computer! 9 10 Number Systems Number Systems ⊂ ⊂ 7365 = 7 × 10 3 + 3 × 10 2 + 6 × 10 1 + 5 × 10 0 The base of a system specifies the number of digits used Base-10: Decimal number system: Digits 0-9 Lets generalize from base 10 to any base: × × × · · · Numbers are written and manipulated using positional notation. If a number in the base- B number system has n digits, it is represented as the following polynomial, where d i represents the digit in × × × × the i -th position 7365: n = 4 d n × B n − 1 + d n − 1 × B n − 2 + · · · + d 2 × B 1 + d 1 7 x 10 3 + 3 x 10 2 + 6 x 10 1 + 5 Each position represents a power of 10 Base-2: Binary number system: Digits: 0-1 Base-8: Octal number system: Digits: 0-7 Base-16: Hexadecimal number system: Digits: 0-9, Letters: A-F 11 12

  4. Binary Number System From Binary to Decimal × × × × × × × d n × B n − 1 + d n − 1 × B n − 2 + · · · + d 2 × B 1 + d 1 d n × 2 n − 1 + d n − 1 × 2 n − 2 + · · · + d 2 × 2 1 + d 1 ⊂ ⊂ Decimal: Base-10: 7365 = 7 × 10 3 + 3 × 10 2 + 6 × 10 1 + 5 × 10 0 × − × × · · · d n × 10 n − 1 + d n − 1 × 10 n − 2 + · · · + d 2 × 10 1 + d 1 Binary: Base-2: 1101 = 1 × 2 3 + 1 × 2 2 + 0 × 2 1 + 1 × × × d n × 2 n − 1 + d n − 1 × 2 n − 2 + · · · + d 2 × 2 1 + d 1 How about from Decimal to Binary? 13 14 Hexadecimal System From Decimal to Binary × × × × d n × B n − 1 + d n − 1 × B n − 2 + · · · + d 2 × B 1 + d 1 1. Divide the value by 2 and record the remainder. 2. As long as the quotient obtained is not 0, continue to divide the newest quotient by two and record the remainder × − × × Hexadecimal Base-16: · · · 3. Now that the quotient of 0 has been obtained, the binary representation of the original value consists d n × 16 n − 1 + d n − 1 × 16 n − 2 + · · · + d 2 × 16 1 + d 1 of the remainders listed from right to left in the order they were recorded. Decimal ! Binary ! Hex ! • Since there are only 10 decimal digits but the Translate 13 to binary: Divide by 2 Record base is 16, we need additional digits: A,B,C,D,E,F 0 0 0000 quotient is 0 the remainder Stop 1 1 0001 • Hexadecimal is shorthand notation for long 2 2 0010 3 3 0011 patterns of bits. 4 4 0100 Divide by 2 Record quotient is 1 the 5 5 0101 • Each group of 4 bits can be represented by a remainder Continue 6 6 0110 7 7 0111 single symbol. 8 8 1000 Divide by 2 Record • 8 bits: 2 digits, 16 bits: 4 digits, 32 bits, 8 digits 9 9 1001 quotient is 3 the remainder A 10 1010 Continue B 11 1011 8 + 2 2 + 1 C 12 1100 10100011 becomes A3 D 13 1101 Divide by 2 Record quotient is 6 E 14 1110 the remainder Continue F 15 1111 A 3 13 = 15 16

  5. Some Examples Information Storage and Processing Goal: To understand how all modern computing systems What is 11000011 in hexadecimal notation? and computation using such systems are based on binary C 3 numbers and operations on them! Computers execute binary computations. Any information we What is 11111101 in hexadecimal notation? process is ultimately encoded and stored as binary numbers! F D Images Video Text Symbols Sound Decimal ! Binary ! Hex ! What is E6 in decimal notation? 0 0 0000 1 1 0001 2 2 0010 2 7 + 2 6 + 2 5 + 2 2 + 2 1 = 230 3 3 0011 4 4 0100 5 5 0101 6 6 0110 1110 0110 7 7 0111 8 8 1000 9 9 1001 E*16 1 + 6*16 0 = 230 A 10 1010 B 11 1011 C 12 1100 14*16 1 + 6*16 0 = 230 Any process on data is ultimately encoded and stored as binary numbers! D 13 1101 E 14 1110 F 15 1111 17 18 BITS - Binary Digits BITS and BYTES Information in a computer is encoded as patterns of 1’s and 0’s. Most computers use blocks of 8 bits, or bytes, as the smallest addressable unit of memory Information = Bits + Context Decimal ! Binary ! Hex ! The context provides an interpretation of the bit patterns! 0 0 0000 1 1 0001 The same bit pattern can mean different things. 2 2 0010 Byte = 8 bits 3 3 0011 4 4 0100 5 5 0101 Binary 00000000 2 to 11111111 2 6 6 0110 For instance, a numerical value, character or a program instruction! 7 7 0111 8 8 1000 Decimal: 0 10 to 255 10 9 9 1001 A 10 1010 Logical Computations Numerical Computations B 11 1011 Hexadecimal 00 16 to FF 16 C 12 1100 D 13 1101 E 14 1110 And, Or 1= true F 15 1111 1 Addition, Subtraction Not 0= false Multiplication, Division 0 Context: Logic Context: Numbers 19 20

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend