Prof. Giancarlo Succi, Ph.D., P.Eng.

Slides:



Advertisements
Similar presentations
Representing Numbers: Integers
Advertisements

2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Floating Point Numbers
Binary Number Systems.
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Data Representation and Computer Arithmetic
Introduction to Number System
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
William Stallings Computer Organization and Architecture 8th Edition
MATH Lesson 2 Binary arithmetic.
Floating Point Numbers
Introduction to Numerical Analysis I
Floating Point Representations
CS2100 Computer Organisation
Department of Computer Science Georgia State University
Data Representation COE 308 Computer Architecture
Backgrounder: Binary Math
Chapter 2 Binary Number Systems.
Dr.Faisal Alzyoud 2/20/2018 Binary Arithmetic.
Bits, Data Types, and Operations
Programming and Data Structure
Digital Logic & Design Adil Waheed Lecture 02.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Dr. Clincy Professor of CS
Lecture No. 4 Number Systems
Number Representation
Introduction To Computer Science
Number Systems and Binary Arithmetic
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Data Representation Binary Numbers Binary Addition
Floating Point Numbers: x 10-18
Floating Point Number system corresponding to the decimal notation
Scientific Notation.
CSE 102 Introduction to Computer Engineering
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
CSCI206 - Computer Organization & Programming
Number Representations
Data Representation Data Types Complements Fixed Point Representation
EEL 3705 / 3705L Digital Logic Design
Arithmetic Logical Unit
Dr. Clincy Professor of CS
Digital Logic & Design Lecture 02.
Approximations and Round-Off Errors Chapter 3
ECEG-3202 Computer Architecture and Organization
Number Representation
Numbers representations
Binary to Decimal Conversion
Floating Point Numbers
Chapter3 Fixed Point Representation
Number Representations
Data Representation COE 308 Computer Architecture
Presentation transcript:

Prof. Giancarlo Succi, Ph.D., P.Eng. E-mail: Giancarlo.Succi@unibz.it Binary Numbers Prof. Giancarlo Succi, Ph.D., P.Eng. E-mail: Giancarlo.Succi@unibz.it Prof. G. Succi, Ph.D., P.Eng.

Content Number and numerals Numeric systems Base conversion Finite precision numbers Binary arithmetic Floating point representations Prof. G. Succi, Ph.D., P.Eng.

Numbers And Numerals Number: abstract entity Numeral: string of symbols that represent a number in a given system The same number can be represented by different numerals in different numeric systems Example 234 in decimal system CCXXXIV using roman system Discuss the role of roman numbers Present the concept of base as “up-to” Start doing the base 2 as 0, 1, 10, 11, 100, 101, … Then show the base 3, 4 etc. Explain why the base 2 is so important The same numeral stands for different numbers if different systems are used Example (10)10=10 (10)2 = ( 2 )10= 2 Prof. G. Succi, Ph.D., P.Eng.

Numeric Systems (1) To define a Numeric System we need: a set of symbols that we will call digits (E.g. 1,2,3, X,K, ….) some rules to build up numbers We can define Positional Numeric System or Non Positional Numeric Systems Non Positional Numeric System: the value of digits in the number is position independent Example In Roman Numeric System: the symbol V means 5 always, but IV  VI …. Prof. G. Succi, Ph.D., P.Eng.

Numeric Systems (2) Positional Numeric System: digit value depends on its position within the number (weight) Each digit represents the coefficient of a power of the base Exponent is given by the position of the digit within the number position m-1 position -1 position -k position m position 0 comma position -2 Prof. G. Succi, Ph.D., P.Eng.

Numeric Systems (3) The Decimal System 125.42 Positional Numeric System: digit value depends on its position within the number (weight) Example The Decimal System 125.42 Prof. G. Succi, Ph.D., P.Eng.

Numeric Systems (4) The Binary System 101.01 Example Prof. G. Succi, Ph.D., P.Eng.

Numeric Systems (5) Other Systems Used Octal System: Example base = 8 symbols used = 0,1,2,3,4,5,6,7 Hexadecimal System: base = 16 symbols used = 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Prof. G. Succi, Ph.D., P.Eng.

Base Conversion (decimal to binary) Is obtained by repeatedly dividing the number by 2, the remainder of division at each step is the digit of the binary number (starting from less significant digits) ( ) 2 10 11010 26 digit t significan more 1 / 3 6 13 less = ï þ ý ü ¾ ® rem The first method is the one used Ask a few students to do it Tell to remember to do it the other way around … or by determining the powers of 2 contained in the number: Prof. G. Succi, Ph.D., P.Eng.

Base Conversion (binary to decimal ) Is obtained by strictly applying the definition: How do we convert binary to hexadecimal? Show the long process and then the shortcut for it. Same for octal. Prof. G. Succi, Ph.D., P.Eng.

Finite precision numbers (1) Finite Precision numbers: numbers with a finite number of digits. Some properties are lost: operators closure distributive, associative properties holes in the representation of real numbers Example Lets use numbers with 2 decimal numbers with sign Interval represented: [+99, -99] Closure respect operator + is lost: 76+30 = ??? (106 is out of the interval) Associative property: 25+ (90-30)  (25+ 90)-30 Prof. G. Succi, Ph.D., P.Eng.

Finite precision numbers (2) Example Lets use consider numbers with just two two decimal digit: Interval represented: [+0.99, -0.99] We cannot represent a number between 0.05 and 0.06 Prof. G. Succi, Ph.D., P.Eng.

Represented Intervals By representing positive integers in binary notation, n digits (bits), cover the interval [0,2n-1] It is easy to note that if the maximum number representable using n bit is X = 2n -1 then to represent number X are necessary n = Int( log2 (X)+1) bits Example using n=3 interval [0, 7] is completely represented 0 000 4 100 1 001 5 101 2 010 6 110 3 011 7 111 Int is the next integer Prof. G. Succi, Ph.D., P.Eng.

Positive and negative integers in base 2 (1) To represent Integer Relative Numbers, if the same number of digits is used, the interval of absolute is halved Several notations are used: Signed Magnitude the first bit is used for the sign 0 : + ; 1 : - n-1 bits are used for the magnitude represented interval: [-2n-1 +1, 2n-1 -1] Note that 0 has two possible representations Example using n=4 interval [-7, 7] is completely represented 5 0101 -5 1101 Representations: 1000 and 0000 Prof. G. Succi, Ph.D., P.Eng.

Positive and negative integers in base 2 (2) One’s Complement a 0 is added on left of positive numbers to change sign the numeral is complemented bit by bit positive numerals start with 0, negative ones with 1 n-1 bits are used for the magnitude represented interval: [-2n-1 +1, 2n-1 -1] Note that 0 has two representations Example using n=4 interval [-7, 7] is completely represented 5 0101 -5 1010 ( -7+2) Representations for 0: 1000 and 0000 Prof. G. Succi, Ph.D., P.Eng.

Positive and negative integers in base 2 (3) Two’s Complement a 0 is added on left of positive numbers negative numbers are obtained by complementing bit by bit the corresponding positive a and then adding 1 positive numerals start with 0, negative ones with 1 n-1 bits are used for the magnitude represented interval: [-2n-1, 2n-1 -1] We earned a number by giving 0 just one representation Example using n=4 interval [-8, 7] is completely represented 5 0101 -5 1011 Prof. G. Succi, Ph.D., P.Eng.

Positive and negative integers in base 2 (4) Excess Notation numbers are represented as a sum of the number with a power of 2 Using n bits excess 2n-1 is used represented interval: [-2n-1, 2n-1 -1] practical rule: numerals are obtained by complementing the highest digit in 2’s complement notation Example using n=4 interval [-8, 7] excess=8 5 5+8 = 13  1101 - 6 - 6+8 = +2  0010 Prof. G. Succi, Ph.D., P.Eng.

Binary Arithmetic (1) the sum Sum in binary notation is performed bit by bit carrying the rest to next digit Example Prof. G. Succi, Ph.D., P.Eng.

Binary Arithmetic (2) the sum in 2’s C In 2’sC sum and subtraction are managed in the same way, just throw away Carry Carry is thrown away If the two terms have different sign the result is always correct. If the two terms have the same sign but the result has a different one …. … we have an ERROR Example What about the sum 100 + 100 using 8 bit representation in 2’sC Overflow Error ! Prof. G. Succi, Ph.D., P.Eng.

Binary Arithmetic (3) multiplication Easy ... repeated addition ….. or the usual rules learned for the product of integers or real numbers can be used, recalling the following multiplication table: 0 1 0 0 0 1 0 1 Prof. G. Succi, Ph.D., P.Eng.

Floating Point Notation Example Using Base 10 Using numerals with 5 digits of the kind  .XXX  EE Mantissa =  .XXX three signed digits 0.1 | m |  1 Exponent =  EE two signed digits -99  e  99 Represented numbers are: Represented interval is Negative Overflow Positive Overflow Positive Underflow Negative Underflow Prof. G. Succi, Ph.D., P.Eng.

Standard IEEE 754 (1985) Standard definition (i.e. architecture independent) Simple precision ( uses 32 bits to represent sign, exponent and mantissa Double precision (uses 64 bits) There are notation using normalized mantissa or not Some configurations of the exponent are reserved (i.e. not standardized) +/- (1 bit) Exponent (8 bit) Mantissa (23 bit) +/- (1 bit) Exponent (11 bit) Mantissa (52 bit) Prof. G. Succi, Ph.D., P.Eng.

Floating Point Sum To sum (or subtract) floating point numbers it is necessary to scale mantissa to have the same exponents in all terms Example n1 + n2 : using standard IEEE 754 notation in 32 bits Note that lower terms is loosing digits Prof. G. Succi, Ph.D., P.Eng.

Floating Point product Multiply mantissa and sum exponents If necessary mantissa is scaled and exponent is incremented/decremented Example n1 x n2 : using standard IEEE 754 notation in 32 bits Prof. G. Succi, Ph.D., P.Eng.

Binary Arithmetic (4) division For your knowledge Binary Arithmetic (4) division Need to represent fractions Prof. G. Succi, Ph.D., P.Eng.

Fractional Representation For your knowledge Fractional Representation Fixed Point Notation: stores numerals as: Floating Point Notation: A n digit floating point number in base b is represented by. Where is a numeral in base b called mantissa normalized with and e is an integer called the exponent. Prof. G. Succi, Ph.D., P.Eng.