IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1


 Dortha Shelton
 9 months ago
 Views:
Transcription
1 IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1
2 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose key characteristic would be a continuous signal A digital signal is one whose key characteristic (e.g. voltage or current) fall into discrete ranges of values Most digital systems utilize two voltage levels 2009, University of Colombo School of Computing 2
3 Advantage of Digital over Analog 2009, University of Colombo School of Computing 3
4 What is a bit A bit is a binary digit, the smallest increment of data on a machine. A bit can hold only one of two values: 0 or 1 Because bits are so small, you rarely work with information one bit at a time. 2009, University of Colombo School of Computing 4
5 Real World Problem Abstract to What is a bit Apply to Algorithm Code for Knowledge Leading to Use to make Operate on Machine Interpret as Model Encode as Data Information 2009, University of Colombo School of Computing 5
6 Bit Storage  Capacitor plates discharged plates charging plates charged 4 5 plates discharging plates discharged Can store 1 of 2 possible states 2009, University of Colombo School of Computing 6
7 What is a bit Byte is an abbreviation for "binary term". A single byte is composed of 8 consecutive bits capable of storing a single character 2009, University of Colombo School of Computing 7
8 Storage Hierarchy 8 Bits = 1 Byte 1024 Bytes = 1 Kilobyte (KB) 1024 KB = 1 Megabyte (MB) 1024 MB = 1 Gigabyte (GB) A word is the default data size for a processor 2009, University of Colombo School of Computing 8
9 Numbering System Decimal System Alphabet = { 0,1,2,3,4,5,6,7,8,9 } Octal System Alphabet = { 0,1,2,3,4,5,6,7 } Hexadecimal System Alphabet = { 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F } Binary System Alphabet = { 0,1 } 2009, University of Colombo School of Computing 9
10 Converting decimal to binary remainder remainder remainder remainder remainder remainder remainder , University of Colombo School of Computing 10
11 Converting decimal to binary remainder remainder remainder remainder remainder remainder 1 2 Most 0 remainder 1 significant bit 2009, University of Colombo School of Computing 11
12 Converting decimal to binary remainder remainder remainder remainder remainder remainder remainder 1 Least significant bit 2009, University of Colombo School of Computing 12
13 Your turn Convert the number to binary 2009, University of Colombo School of Computing 13
14 Bit position Converting binary to decimal Decimal value 2009, University of Colombo School of Computing 14
15 Bit position Converting binary to decimal Decimal value 2009, University of Colombo School of Computing 15
16 Converting binary to decimal Example: Convert the unsigned binary number to decimal , University of Colombo School of Computing 16
17 Converting binary to decimal , University of Colombo School of Computing 17
18 Converting binary to decimal , University of Colombo School of Computing 18
19 Converting binary to decimal = 154 So, in unsigned binary is 154 in decimal 2009, University of Colombo School of Computing 19
20 Converting binary to decimal Example: Convert the decimal number 105 to unsigned binary 2009, University of Colombo School of Computing 20
21 Converting binary to decimal Q. Does 128 fit into 105? A. No Next, consider the difference: 1050*128 = , University of Colombo School of Computing 21
22 Converting binary to decimal Q. Does 64 fit into 105? A. Yes Next, consider the difference: 1051*64 = , University of Colombo School of Computing 22
23 Q. Does 32 fit into 41? A. Yes Converting binary to decimal Next, consider the difference: = , University of Colombo School of Computing 23
24 Your turn Convert the number to decimal 2009, University of Colombo School of Computing 24
25 Converting binary numbers Decimal System 0,1,2,3,4,5,6,7,8,9,10,11,12,13 Binary System 0,1,10,11,100,101,110,111,1000,1001,1010,1011,1100, , University of Colombo School of Computing 25
26 Your turn Using 5 binary digits how many numbers you can represent? 2009, University of Colombo School of Computing 26
27 Hexadecimal Notation HEX Bit Pattern HEX Bit Pattern A B C D E F , University of Colombo School of Computing 27
28 Your turn How many binary digits need to represent a hexadecimal digit? 2009, University of Colombo School of Computing 28
29 Converting hexadecimal numbers Decimal System 0,1,2,3,4,5,6,7,8,9,10,11,12,13 Hexadecimal System 0,1,,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,13,14,15, 16,17,18,19,1A,1B,1C,1D,1E,1F , University of Colombo School of Computing 29
30 Binary to Hexadecimal Conversion = 96 Hexadecimal 2009, University of Colombo School of Computing 30
31 Binary to Hexadecimal Conversion D B = DB Hexadecimal 2009, University of Colombo School of Computing 31
32 Your turn Convert the following binary string to Hexadecimal , University of Colombo School of Computing 32
33 Binary to Hexadecimal Conversion F = 29F5 Hex 2009, University of Colombo School of Computing 33
34 Computer Number System 2009, University of Colombo School of Computing 34
35 ASCII Codes American Standard Code for Information Interchange (ASCII) Use bit patterns of length seven to represent Letters of English alphabet: a  z and A  Z Digits: 0 9 Punctuation symbols: (, ), [, ], {, },,,!, /, \ Arithmetic Operation symbols: +, , *, <, >, = Special symbols: (space), %, $, #, ^ 2 7 = 128 characters can be represented by ASCII 2009, University of Colombo School of Computing 35
36 Character Representation: ASCII Table Symbol ASCII Symbol ASCII Symbol ASCII Symbol ASCII (space) A a ! B b C c # D d $ E e % F f & G g , University of Colombo School of Computing 36
37 Character Representation: ASCII Table 2009, University of Colombo School of Computing 37
38 Character Representation: ASCII Table As computers became more reliable the need for parity bit faded. Computer manufacturers extended ASCII to provide more characters, e.g., international characters Used ranges (2 7 ) (2 81) 2009, University of Colombo School of Computing 38
39 The BINARY string can have two meanings! the CHARACTER 5 in ASCII AND... Your turn the DECIMAL NUMBER 53 in BINARY Notation 2009, University of Colombo School of Computing 39
40 Character Representation: Unicode EBCDIC and ASCII are built around the Latin alphabet Are restricted in their ability for representing non Latin alphabet Countries developed their own codes for native languages Unicode: 16bit system that can encode the characters of most languages 16 bits = 2 16 = 65,636 characters 2009, University of Colombo School of Computing 40
41 Character Representation: Unicode The Java programming language and some operating systems now use Unicode as their default character code Unicode codespace is divided into six parts The first part is for Western alphabet codes, including English, Greek, and Russian Downward compatible with ASCII and Latin1 character sets 2009, University of Colombo School of Computing 41
42 Character Representation: Unicode 2009, University of Colombo School of Computing 42
43 Character Representation: Example English section of Unicode Table ACSII equivalent of A is Unicode is equivalent of A: Full chart list: , University of Colombo School of Computing 43
44 Performing Arithmetic 2009, University of Colombo School of Computing 44
45 Binary Addition = = = = 10 (carry: 1) E.g (carry) = , University of Colombo School of Computing 45
46 Binary Subtraction 00 = = 1 (with borrow) 10 = = 0 E.g. * * * (borrow) = , University of Colombo School of Computing 46
47 Binary Multiplication E.g x = , University of Colombo School of Computing 47
48 Binary Division E.g , University of Colombo School of Computing 48
49 Representing Numbers Problems of number representation Positive and negative Radix point Range of representation Different ways to represent numbers Unsigned representation: nonnegative integers Signed representation: integers Floatingpoint representation: fractions 2009, University of Colombo School of Computing 49
50 Unsigned and Signed Numbers Unsigned binary numbers Have 0 and 1 to represent numbers Only positive numbers stored in binary The Smallest binary number would be which equals to 0 The largest binary number would be which equals = 255 = Therefore the range is (256 numbers) 2009, University of Colombo School of Computing 50
51 Unsigned and Signed Numbers Signed binary numbers Have 0 and 1 to represent numbers The leftmost bit is a sign bit 0 for positive 1 for negative Sign bit 2009, University of Colombo School of Computing 51
52 Unsigned and Signed Numbers Signed binary numbers The Smallest positive binary number is which equals to 0 The largest positive binary number is which equals = 127 = Therefore the range for positive numbers is (128 numbers) 2009, University of Colombo School of Computing 52
53 Negative Numbers in Binary Problems with simple signed representation Two representation of zero: + 0 and and Need to consider both sign and magnitude in arithmetic E.g. 5 3 = 5 + (3) = = = , University of Colombo School of Computing 53
54 Negative Numbers in Binary Problems with simple signed representation Need to consider both sign and magnitude in arithmetic E.g. = 18 + (18) = = = , University of Colombo School of Computing 54
55 Negative Numbers in Binary The representation of a negative integer (Two s Complement) is established by: Start from the signed binary representation of its positive value Copy the bit pattern from right to left until a 1 has been copied Complement the remaining bits: all the 1 s with 0 s, and all the 0 s with 1 s An exception: = , University of Colombo School of Computing 55
56 Your turn What is the SMALLEST and LARGEST signed binary numbers that can be stored in 1 BYTE 2009, University of Colombo School of Computing 56
57 Two s Compliment (8 bit pattern) = = = = = = = = = = , University of Colombo School of Computing 57
58 Two s Compliment benefits One representation of zero Arithmetic works easily Negating is fairly easy 2009, University of Colombo School of Computing 58
59 Ranges of Integer Representation 8bit unsigned binary representation Largest number: = Smallest number: = bit two s complement representation Largest number: = Smallest number: = The problem of overflow = in two s complement 2009, University of Colombo School of Computing 59
60 Geometric Depiction of Two s Complement Integers 2009, University of Colombo School of Computing 60
61 Integer Data Types in C++ Type Size in Bits Range unsigned int int unsigned long int 32 0 to 4,294,967,295 long int 322,147,483,648 to 2,147,483, , University of Colombo School of Computing 61
62 = the SUM of... Fractions in Decimal 7 * 103 = 7 / * 102 = 5 / * 101 = 3 / 10 6 * 10 0 = 6 1 * 10 1 = 10 7 / / / = / , University of Colombo School of Computing 62
63 = the SUM of... Fractions in Binary 1 * 23 = 1 / 8 1 * 22 = 1 / 4 0 * 21 = 0 0 * 2 0 = 0 1 * 2 1 = 2 1 / / = 2 3 / 8 i.e = 2 3 / 8 in Decimal (Base 10) 2009, University of Colombo School of Computing 63
64 Your turn What is in Base 10? 2009, University of Colombo School of Computing 64
65 Fractions in Binary = the SUM of... 1 * 24 = 1 / 16 0 * 23 = 0 1 * 22 = 1 / 4 0 * 21 = 0 1 * 2 0 = 1 1 * 2 1 = 2 0 * 2 2 = 0 1 / / = / , University of Colombo School of Computing 65
66 Decimal Scientific Notation Consider the following representation in decimal number = x = x =.2452 x x 10 3 has the following components: a Mantissa = an Exponent = 3 a Base = , University of Colombo School of Computing 66
67 Floating Point Representation of Fractions Scientific notation for binary. Examples = x = x = x , University of Colombo School of Computing 67
68 Floating Point Format in 1 Byte RADIX POINT SIGN = 0 (+ve) 1 (ve) EXPONENT in EXCESS FOUR Notation MANTISSA EXPONENT SIGN 2009, University of Colombo School of Computing 68
69 Floating Point Format in 1 Byte To STORE the number / 8 = in FLOATING POINT NOTATION STORE the SIGN BIT 2009, University of Colombo School of Computing 69
70 Floating Point Format in 1 Byte To STORE the number / 8 = in FLOATING POINT NOTATION STORE the SIGN BIT , University of Colombo School of Computing 70
71 Floating Point Format in 1 Byte To STORE the number / 8 = in FLOATING POINT NOTATION STORE the MANTISSA BITS , University of Colombo School of Computing 71
72 Floating Point Format in 1 Byte To STORE the number / 8 = in FLOATING POINT NOTATION STORE the MANTISSA BITS , University of Colombo School of Computing 72
73 Floating Point Format in 1 Byte To STORE the number / 8 = in FLOATING POINT NOTATION STORE the EXPONENT BITS , University of Colombo School of Computing 73
74 Bit Pattern Excessk Representation Value Representation EXCESS THREE NOTATION An excess notation system using bit pattern of length three 2009, University of Colombo School of Computing 74
75 Excessk Representation For N bit numbers, k is 2 N11 E.g., for 4bit integers, k is 7 The actual value of each bit string is its unsigned value minus k To represent a number in excessk, add k 2009, University of Colombo School of Computing 75
76 Excessk Representation sliding ruler Unsigned k = 7 Excessk , University of Colombo School of Computing 76
77 Floating Point Format in 1 Byte To STORE the number / 8 = in FLOATING POINT NOTATION STORE the EXPONENT BITS , University of Colombo School of Computing 77
78 Floating Point Format in 1 Byte To STORE the number / 4 = in FLOATING POINT NOTATION STORE the SIGN BIT 2009, University of Colombo School of Computing 78
79 Floating Point Format in 1 Byte To STORE the number / 4 = in FLOATING POINT NOTATION STORE the SIGN BIT , University of Colombo School of Computing 79
80 Floating Point Format in 1 Byte To STORE the number / 4 = in FLOATING POINT NOTATION STORE the MANTISSA BITS , University of Colombo School of Computing 80
81 Floating Point Format in 1 Byte To STORE the number / 4 = in FLOATING POINT NOTATION STORE the MANTISSA BITS , University of Colombo School of Computing 81
82 Floating Point Format in 1 Byte To STORE the number / 4 = in FLOATING POINT NOTATION STORE the EXPONENT BITS , University of Colombo School of Computing 82
83 Floating Point Format in 1 Byte To STORE the number / 4 = in FLOATING POINT NOTATION STORE the EXPONENT BITS , University of Colombo School of Computing 83
84 Your turn Write down the FLOATING POINT form for the number + 11 / 64? 2009, University of Colombo School of Computing 84
85 SOLUTION: + 11 / 64 ( ) 1. STORE the SIGN BIT 2009, University of Colombo School of Computing 85
86 SOLUTION: + 11 / 64 ( ) 1. STORE the SIGN BIT , University of Colombo School of Computing 86
87 SOLUTION: + 11 / 64 ( ) 2. STORE the MANTISSA BITS , University of Colombo School of Computing 87
88 SOLUTION: + 11 / 64 ( ) 2. STORE the MANTISSA BITS , University of Colombo School of Computing 88
89 SOLUTION: + 11 / 64 ( ) 3. STORE the EXPONENT BITS , University of Colombo School of Computing 89
90 Converting FP Binary to Decimal Example... CONVERT to decimal steps Convert EXPONENT (EXCESS 4) 2. Apply EXPONENT to MANTISSA 3. Convert BINARY Fraction 4. Apply SIGN 2009, University of Colombo School of Computing 90
91 SOLUTION: CONVERT THE EXPONENT = , University of Colombo School of Computing 91
92 SOLUTION: APPLY the EXPONENT to the MANTISSA , University of Colombo School of Computing 92
93 SOLUTION: CONVERT from BINARY FRACTION / / 8 = 1 5 / , University of Colombo School of Computing 93
94 SOLUTION: APPLY the SIGN ( / / 8 ) = / , University of Colombo School of Computing 94
95 ROUNDOFF ERRORS CONSIDER the FLOATING POINT Form of the number / , University of Colombo School of Computing 95
96 ROUNDOFF OFF ERRORS +2 5 / 8 1. CONVERT to BINARY FRACTION / 8 = i.e / / , University of Colombo School of Computing 96
97 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE SIGN BIT , University of Colombo School of Computing 97
98 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE SIGN BIT , University of Colombo School of Computing 98
99 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE MANTISSA , University of Colombo School of Computing 99
100 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE MANTISSA , University of Colombo School of Computing 100
101 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE MANTISSA , University of Colombo School of Computing 101
102 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE MANTISSA , University of Colombo School of Computing 102
103 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE EXPONENT , University of Colombo School of Computing 103
104 ROUNDOFF OFF ERRORS +2 5 / 8 = STORE THE EXPONENT Converting this back to DECIMAL we get / 4 i.e. a ROUND OFF ERROR of 1 / , University of Colombo School of Computing 104
105 Range of FP Representation What is the BIGGEST and SMALLEST can be represented by onebyte floating point notation 2009, University of Colombo School of Computing 105
106 Range of FP Representation The biggest number can be represented by onebyte floating point notation is: = x 2 4 = = , University of Colombo School of Computing 106
107 Range of FP Representation The Smallest positive number can be represented by onebyte floating point notation is: = x 23 = = + 1 / , University of Colombo School of Computing 107
108 Range of FP Representation The largest negative number can be represented by onebyte floating point notation is: = x 23 = =  1 / , University of Colombo School of Computing 108
109 Range of FP Representation The smallest number can be represented by onebyte floating point notation is: = x 2 4 = = , University of Colombo School of Computing 109
110 Range of FP Representation What is the SOLUTION for this??? 2009, University of Colombo School of Computing 110
111 FloatingPoint Data types in C++ Type Size in Bits Range float E38 to 3.4E+38 Six digits of precision double E308 to 1.7E+308 Ten digits of precision long double E4932 to 3.4E+4932 Ten digits of precision 2009, University of Colombo School of Computing 111
112 FloatingPoint Representation Sign bit Biased Exponent Significand or Mantissa +/. Mantissa x 2 exponent Point is actually fixed between sign bit and body of Mantissa Exponent indicates place value (point position) 2009, University of Colombo School of Computing 112
113 FloatingPoint Representation Mantissa is stored in 2 s compliment Exponent is in excess notation 8 bit exponent field Pure range is Subtract 127 to get correct value Range 127 to , University of Colombo School of Computing 113
114 FloatingPoint Representation Floating Point numbers are usually normalized i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1 Since it is always 1 there is no need to store it Where numbers are normalized to give a single digit before the decimal point E.g x , University of Colombo School of Computing 114
115 FloatingPoint Representation 2009, University of Colombo School of Computing 115
116 Floating Point Representation: Expressible Numbers 2009, University of Colombo School of Computing 116
117 Representing the Mantissa The mantissa has to be in the range 1 mantissa < base Therefore If we use base 2, the digit before the point must be a 1 So we don't have to worry about storing it We get 24 bits of precision using 23 bits 24 bits of precision are equivalent to a little over 7 decimal digits: 24 log , University of Colombo School of Computing 117
118 Representing the Mantissa Suppose we want to represent π: That means that we can only represent it as: (if we truncate) (if we round) 2009, University of Colombo School of Computing 118
119 Representing the Mantissa The IEEE standard restricts exponents to the range: 126 exponent +127 The exponents 127 and +128 have special meanings: If exponent = 127, the stored value is 0 If exponent = 128, the stored value is 2009, University of Colombo School of Computing 119
120 Floating Point Overflow Floating point representations can overflow, e.g., = , University of Colombo School of Computing 120
121 Floating Point Underflow Floating point numbers can also get too small, e.g., = , University of Colombo School of Computing 121
122 Floating Point Representation: Double Precision IEEE754 Double Precision Standard 64 bits: 1 bit sign 52 bit mantissa 11 bit exponent Exponent range is to k = = , University of Colombo School of Computing 122
123 Limitations Floatingpoint representations only approximate real numbers Using a greater number of bits in a representation can reduce errors but can never eliminate them Floating point errors Overflow/underflow can cause programs to crash Can lead to erroneous results / hard to detect 2009, University of Colombo School of Computing 123
124 Floating Point Addition Five steps to add two floating point numbers: 1. Express the numbers with the same exponent (denormalize) 2. Add the mantissas 3. Adjust the mantissa to one digit/bit before the point (renormalize) 4. Round or truncate to required precision 5. Check for overflow/underflow 2009, University of Colombo School of Computing 124
125 Thank You 2009, University of Colombo School of Computing 125
Module 2: Computer Arithmetic
Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N
More information10.1. Unit 10. Signed Representation Systems Binary Arithmetic
0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system
More informationFloating Point Arithmetic
Floating Point Arithmetic CS 365 FloatingPoint What can be represented in N bits? Unsigned 0 to 2 N 2s Complement 2 N1 to 2 N11 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678
More informationCHAPTER 2 Data Representation in Computer Systems
CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting
More informationInf2C  Computer Systems Lecture 2 Data Representation
Inf2C  Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack
More informationCHAPTER 2 Data Representation in Computer Systems
CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting
More informationFloatingpoint Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.
Floatingpoint Arithmetic Reading: pp. 312328 FloatingPoint Representation Nonscientific floating point numbers: A noninteger can be represented as: 2 4 2 3 2 2 2 1 2 0.21 22 23 24 where you sum
More information15213 Recitation 2: Floating Point
15213 Recitation 2: Floating Point 1 Introduction This handout will introduce and test your knowledge of the floating point representation of real numbers, as defined by the IEEE standard. This information
More informationDigital Computers and Machine Representation of Data
Digital Computers and Machine Representation of Data K. Cooper 1 1 Department of Mathematics Washington State University 2013 Computers Machine computation requires a few ingredients: 1 A means of representing
More informationDRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.
Data Representation Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic 0 (0 volts) and one for logic
More informationData Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.
Data Representation Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic ( volts) and one for logic (3.3
More informationNumber Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example
Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,
More informationA complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation
Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers
More informationFloating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !
Floating point Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties Next time! The machine model Chris Riesbeck, Fall 2011 Checkpoint IEEE Floating point Floating
More information1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM
1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number
More informationData Representation Floating Point
Data Representation Floating Point CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides via Jason Fritts Today: Floating Point Background:
More informationChapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation
Chapter 2 Float Point Arithmetic Topics IEEE Floating Point Standard Fractional Binary Numbers Rounding Floating Point Operations Mathematical properties Real Numbers in Decimal Notation Representation
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize
More informationSigned umbers. Sign/Magnitude otation
Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,
More informationECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationFloating Point Numbers. Lecture 9 CAP
Floating Point Numbers Lecture 9 CAP 3103 06162014 Review of Numbers Computers are made to deal with numbers What can we represent in N bits? 2 N things, and no more! They could be Unsigned integers:
More informationLogic, Words, and Integers
Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits
More informationNumber Systems and Computer Arithmetic
Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction Rformat Iformat... integer data number text
More informationComputer Arithmetic Ch 8
Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic FloatingPoint Representation FloatingPoint Arithmetic 1 Arithmetic Logical Unit (ALU) (2) Does all work in CPU (aritmeettislooginen
More informationChapter 1. Data Storage Pearson AddisonWesley. All rights reserved
Chapter 1 Data Storage 2007 Pearson AddisonWesley. All rights reserved Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns
More informationDigital Fundamentals
Digital Fundamentals Tenth Edition Floyd Chapter 1 Modified by Yuttapong Jiraraksopakun Floyd, Digital Fundamentals, 10 th 2008 Pearson Education ENE, KMUTT ed 2009 Analog Quantities Most natural quantities
More informationUNIT  I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS
UNIT  I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and
More informationScientific Computing. Error Analysis
ECE257 Numerical Methods and Scientific Computing Error Analysis Today s s class: Introduction to error analysis Approximations RoundOff Errors Introduction Error is the difference between the exact solution
More information1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
CS 64 Lecture 2 Data Representation Reading: FLD 1.21.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1
More informationCS101 Lecture 04: Binary Arithmetic
CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary
More informationCharacters, Strings, and Floats
Characters, Strings, and Floats CS 350: Computer Organization & Assembler Language Programming 9/6: pp.8,9; 9/28: Activity Q.6 A. Why? We need to represent textual characters in addition to numbers. Floatingpoint
More informationC NUMERIC FORMATS. Overview. IEEE SinglePrecision Floatingpoint Data Format. Figure C0. Table C0. Listing C0.
C NUMERIC FORMATS Figure C. Table C. Listing C. Overview The DSP supports the 32bit singleprecision floatingpoint data format defined in the IEEE Standard 754/854. In addition, the DSP supports an
More information1. Which of the following Boolean operations produces the output 1 for the fewest number of input patterns?
This is full of Test bank for Computer Science An Overview 12th Edition by Brookshear SM https://getbooksolutions.com/download/computerscienceanoverview12theditionbybrookshearsm Test Bank Chapter
More informationSigned Binary Numbers
Signed Binary Numbers Unsigned Binary Numbers We write numbers with as many digits as we need: 0, 99, 65536, 15000, 1979, However, memory locations and CPU registers always hold a constant, fixed number
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 18, 2017 at 12:48 CS429 Slideset 4: 1 Topics of this Slideset
More information3.5 Floating Point: Overview
3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer
More informationFloating point. Today. IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.
Floating point Today IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time The machine model Fabián E. Bustamante, Spring 2010 IEEE Floating point Floating point
More informationIBM 370 Basic Data Types
IBM 370 Basic Data Types This lecture discusses the basic data types used on the IBM 370, 1. Two s complement binary numbers 2. EBCDIC (Extended Binary Coded Decimal Interchange Code) 3. Zoned Decimal
More informationNumber System (Different Ways To Say How Many) Fall 2016
Number System (Different Ways To Say How Many) Fall 2016 Introduction to Information and Communication Technologies CSD 102 Email: mehwish.fatima@ciitlahore.edu.pk Website: https://sites.google.com/a/ciitlahore.edu.pk/ict/
More informationFloating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.
class04.ppt 15213 The course that gives CMU its Zip! Topics Floating Point Jan 22, 2004 IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Floating Point Puzzles For
More informationSystems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties
Systems I Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IEEE Floating Point IEEE Standard 754 Established in 1985 as uniform standard for
More informationCSC201, SECTION 002, Fall 2000: Homework Assignment #2
1 of 7 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #2 DUE DATE Monday, October 2, at the start of class. INSTRUCTIONS FOR PREPARATION Neat, in order, answers easy to find. Staple
More informationCS321. Introduction to Numerical Methods
CS31 Introduction to Numerical Methods Lecture 1 Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506 0633 August 5, 017 Number
More informationumber Systems bit nibble byte word binary decimal
umber Systems Inside today s computers, data is represented as 1 s and 0 s. These 1 s and 0 s might be stored magnetically on a disk, or as a state in a transistor. To perform useful operations on these
More informationFundamentals of Programming Session 2
Fundamentals of Programming Session 2 Instructor: Reza EntezariMaleki Email: entezari@ce.sharif.edu 1 Fall 2013 Sharif University of Technology Outlines Programming Language Binary numbers Addition Subtraction
More informationIEEE754 floatingpoint
IEEE754 floatingpoint Real and floatingpoint numbers Real numbers R form a continuum  Rational numbers are a subset of the reals  Some numbers are irrational, e.g. π Floatingpoint numbers are an
More informationSystem Programming CISC 360. Floating Point September 16, 2008
System Programming CISC 360 Floating Point September 16, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Powerpoint Lecture Notes for Computer Systems:
More informationFive classic components
CS/COE0447: Computer Organization and Assembly Language Chapter 3 modified by Bruce Childers original slides by Sangyeun Cho Dept. of Computer Science Five classic components I am like a control tower
More informationChapter 2: Number Systems
Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This twovalued number system is called binary. As presented earlier, there are many
More informationData Storage. Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J.
Data Storage Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J. Glenn Brookshear Copyright 2012 Pearson Education, Inc. Data Storage Bits
More information4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning
4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.
More informationCS311 Lecture: Representing Information in Binary Last revised 8/2707
CS311 Lecture: Representing Information in Binary Last revised 8/2707 Objectives: 1. To review binary representation for unsigned integers 2. To introduce octal and hexadecimal shorthands 3. To review
More informationUnit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation
3.1 3.2 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based
More information9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System
For Your Amusement Number Systems and Number Representation Jennifer Rexford Question: Why do computer programmers confuse Christmas and Halloween? Answer: Because 25 Dec = 31 Oct  http://www.electronicsweekly.com
More informationDeclaring Floating Point Data
Declaring Floating Point Data There are three ways to declare floating point storage. These are E D L Single precision floating point, Double precision floating point, and Extended precision floating point.
More informationECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays
Assembly Programming Arrays Assembly Programming Arrays Array For Loop Example: unsigned short a[]; for(j=; j
More informationNumbers and Representations
Çetin Kaya Koç http://koclab.cs.ucsb.edu/teaching/cs192 koc@cs.ucsb.edu Çetin Kaya Koç http://koclab.cs.ucsb.edu Fall 2016 1 / 38 Outline Computational Thinking Representations of integers Binary and decimal
More informationFloating Point Numbers
Floating Point Numbers Summer 8 Fractional numbers Fractional numbers fixed point Floating point numbers the IEEE 7 floating point standard Floating point operations Rounding modes CMPE Summer 8 Slides
More informationBinary Addition & Subtraction. Unsigned and Sign & Magnitude numbers
Binary Addition & Subtraction Unsigned and Sign & Magnitude numbers Addition and subtraction of unsigned or sign & magnitude binary numbers by hand proceeds exactly as with decimal numbers. (In fact this
More informationCMSC 313 Lecture 03 Multiplebyte data bigendian vs littleendian sign extension Multiplication and division Floating point formats Character Codes
Multiplebyte data CMSC 313 Lecture 03 bigendian vs littleendian sign extension Multiplication and division Floating point formats Character Codes UMBC, CMSC313, Richard Chang 45 Chapter
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationEEM 232 Digital System I
EEM 232 Digital System I Instructor : Assist. Prof. Dr. Emin Germen egermen@anadolu.edu.tr Course Book : Logic and Computer Design Fundamentals by Mano & Kime Third Ed/Fourth Ed.. Pearson Grading 1 st
More informationAppendix. Numbering Systems. In this Appendix
Numbering Systems ppendix n this ppendix ntroduction... inary Numbering System... exadecimal Numbering System... Octal Numbering System... inary oded ecimal () Numbering System... 5 Real (Floating Point)
More informationDigital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand
Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary
More informationName: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.
CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1 Name: Question Points I. /34 II. /30 III. /36 TOTAL: /100 Instructions: 1. This is a closedbook, closednotes exam. 2. You
More informationLecture (03) Binary Codes Registers and Logic Gates
Lecture (03) Binary Codes Registers and Logic Gates By: Dr. Ahmed ElShafee Binary Codes Digital systems use signals that have two distinct values and circuit elements that have two stable states. binary
More informationThe Sign consists of a single bit. If this bit is '1', then the number is negative. If this bit is '0', then the number is positive.
IEEE 754 Standard  Overview Frozen Content Modified by on 13Sep2017 Before discussing the actual WB_FPU  Wishbone Floating Point Unit peripheral in detail, it is worth spending some time to look at
More informationTUTORIAL 1 COMPUTER ORGANISATION TIT402
TUTORIAL 1 COMPUTER ORGANISATION TIT402 Q1.(43) 10 = (? ) 2 s (GATE 2000) a)01010101 b)11010101 c)00101011 d)10101011 Q2.The 2 s complement representation of (539) 10 in hexadecimal is (GATE 2001) a)abe
More informationPrinciples of Computer Architecture. Chapter 3: Arithmetic
31 Chapter 3  Arithmetic Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 3: Arithmetic 32 Chapter 3  Arithmetic 3.1 Overview Chapter Contents 3.2 Fixed Point Addition
More informationMore Programming Constructs  Introduction
More Programming Constructs  Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and
More informationOctal and Hexadecimal Integers
Octal and Hexadecimal Integers CS 350: Computer Organization & Assembler Language Programming A. Why? Octal and hexadecimal numbers are useful for abbreviating long bitstrings. Some operations on octal
More informationFLOATING POINT NUMBERS
FLOATING POINT NUMBERS Robert P. Webber, Longwood University We have seen how decimal fractions can be converted to binary. For instance, we can write 6.25 10 as 4 + 2 + ¼ = 2 2 + 2 1 + 22 = 1*2 2 + 1*2
More informationOn a 64bit CPU. Size/Range vary by CPU model and Word size.
On a 64bit CPU. Size/Range vary by CPU model and Word size. unsigned short x; //range 0 to 65553 signed short x; //range ± 32767 short x; //assumed signed There are (usually) no unsigned floats or doubles.
More informationCS101 Introduction to computing Floating Point Numbers
CS101 Introduction to computing Floating Point Numbers A. Sahu and S. V.Rao Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Need to floating point number Number representation
More informationCPS311 Lecture: Representing Information in Binary Last revised Sept. 25, 2017
CPS311 Lecture: Representing Information in Binary Last revised Sept. 25, 2017 Objectives: 1. To review binary representation for unsigned integers 2. To introduce octal and hexadecimal shorthands 3. To
More informationChapter 2 Binary Values and Number Systems
Chapter 2 Binary Values and Number Systems Chapter Goals 10 進位 2 / 8 / 16 進位 進位系統間轉換 各進位系統小數表示 各進位系統加減法 各進位系統乘除法 2 24 6 Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to
More informationP( Hit 2nd ) = P( Hit 2nd Miss 1st )P( Miss 1st ) = (1/15)(15/16) = 1/16. P( Hit 3rd ) = (1/14) * P( Miss 2nd and 1st ) = (1/14)(14/15)(15/16) = 1/16
CODING and INFORMATION We need encodings for data. How many questions must be asked to be certain where the ball is. (cases: avg, worst, best) P( Hit 1st ) = 1/16 P( Hit 2nd ) = P( Hit 2nd Miss 1st )P(
More informationComputer Systems C S Cynthia Lee
Computer Systems C S 1 0 7 Cynthia Lee 2 Today s Topics LECTURE: Floating point! Real Numbers and Approximation MATH TIME! Some preliminary observations on approximation We know that some noninteger numbers
More informationIEEE Standard 754 Floating Point Numbers
IEEE Standard 754 Floating Point Numbers Steve Hollasch / Last update 2005Feb24 IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intelbased
More information4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning
4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.
More informationCS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions
CS/EE2 INTRODUCTION TO COMPUTER ENGINEERING SPRING 23 DUE : February 22, 23 HOMEWORK I READ : Related portions of the following chapters : È Chapter È Chapter 2 È Appendix E ASSIGNMENT : There are eight
More informationData Representation and Networking
Data Representation and Networking Instructor: Dmitri A. Gusev Spring 2007 CSC 120.02: Introduction to Computer Science Lecture 3, January 30, 2007 Data Representation Topics Covered in Lecture 2 (recap+)
More informationChapter 3: part 3 Binary Subtraction
Chapter 3: part 3 Binary Subtraction Iterative combinational circuits Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary addersubtractors Signed binary
More informationAdministrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION
Administrivia CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries Jan Plane & Alan Sussman {jplane, als}@cs.umd.edu Project 6 due next Friday, 12/10 public tests posted
More informationCSCI 2212: Intermediate Programming / C Chapter 15
... /34 CSCI 222: Intermediate Programming / C Chapter 5 Alice E. Fischer October 9 and 2, 25 ... 2/34 Outline Integer Representations Binary Integers Integer Types Bit Operations Applying Bit Operations
More informationNUMBER SYSTEMS AND CODES
C H A P T E R 69 Learning Objectives Number Systems The Decimal Number System Binary Number System Binary to Decimal Conversion Binary Fractions DoubleDadd Method Decimal to Binary Conversion Shifting
More informationDescription Hex M E V smallest value > largest denormalized negative infinity number with hex representation 3BB0 
CSE2421 HOMEWORK #2 DUE DATE: MONDAY 11/5 11:59pm PROBLEM 2.84 Given a floatingpoint format with a kbit exponent and an nbit fraction, write formulas for the exponent E, significand M, the fraction
More informationClasses of Real Numbers 1/2. The Real Line
Classes of Real Numbers All real numbers can be represented by a line: 1/2 π 1 0 1 2 3 4 real numbers The Real Line { integers rational numbers nonintegral fractions irrational numbers Rational numbers
More informationLearning the Binary System
Learning the Binary System www.brainlubeonline.com/counting_on_binary/ Formated to L A TEX: /25/22 Abstract This is a document on the base2 abstract numerical system, or Binary system. This is a VERY
More informationChapter 3. Fundamental Data Types
Chapter 3. Fundamental Data Types ByoungTak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr Variable Declaration
More informationBuilding a Test Suite
Program #3 Is on the web Exam #1 Announcements Today, 6:00 7:30 in Armory 0126 Makeup Exam Friday March 9, 2:00 PM room TBA Reading Notes (Today) Chapter 16 (Tuesday) 1 API: Building a Test Suite Int createemployee(char
More informationIndependent Representation
Independent Representation 1 Integer magnitude + 1 2 3 4 5 6 7 8 9 0 Float sign sign of exponent mantissa On standard 32 bit machines: INT_MAX = 2147483647 which gives 10 digits of precision, (i.e. the
More informationNumeric Precision 101
www.sas.com > Service and Support > Technical Support TS Home Intro to Services News and Info Contact TS Site Map FAQ Feedback TS654 Numeric Precision 101 This paper is intended as a basic introduction
More informationEE 109 Unit 6 Binary Arithmetic
EE 109 Unit 6 Binary Arithmetic 1 2 Semester Transition Point At this point we are going to start to transition in our class to look more at the hardware organization and the lowlevel software that is
More informationComputer Systems Programming. Practice Midterm. Name:
Computer Systems Programming Practice Midterm Name: 1. (4 pts) (K&R Ch 14) What is the output of the following C code? main() { int i = 6; int j = 35; printf( %d %d\n,i++, ++j); i = i >
More information1.2 Roundoff Errors and Computer Arithmetic
1.2 Roundoff Errors and Computer Arithmetic 1 In a computer model, a memory storage unit word is used to store a number. A word has only a finite number of bits. These facts imply: 1. Only a small set
More informationLecture Notes: FloatingPoint Numbers
Lecture Notes: FloatingPoint Numbers CS227Scientific Computing September 8, 2010 What this Lecture is About How computers represent numbers How this affects the accuracy of computation Positional Number
More informationLecture 5. Computer Arithmetic. Ch 9 [Stal10] Integer arithmetic Floatingpoint arithmetic
Lecture 5 Computer Arithmetic Ch 9 [Stal10] Integer arithmetic Floatingpoint arithmetic ALU ALU = Arithmetic Logic Unit (aritmeettislooginen yksikkö) Actually performs operations on data Integer and
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 TYPES TYPES Programs have to store and process different kinds of data, such as integers and floatingpoint numbers, in different ways. To this end, the compiler needs to
More information8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. FixedPoint Representations Support Fractions
University of Illinois at UrbanaChampaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Fixed and FloatingPoint Representations In Binary, We Have A Binary Point Let
More information