Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.

Slides:



Advertisements
Similar presentations
Binary Number Systems.
Advertisements

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
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.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.
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
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
The Binary Number System
Binary Number Systems.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Binary Representation and Computer Arithmetic
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
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
Number Systems Spring Semester 2013Programming and Data Structure1.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Binary Fractions. Fractions A radix separates the integer part from the fraction part of a number Columns to the right of the radix have negative.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Floating Point Arithmetic
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
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.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Numbers
Fundamentals of Computer Science
Binary Fractions.
Programming and Data Structure
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Introduction To Computer Science
Data Representation Binary Numbers Binary Addition
William Stallings Computer Organization and Architecture 7th Edition
Data Structures Mohammed Thajeel To the second year students
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Presentation transcript:

Operators & Identifiers The Data Elements

Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division ( integer remainder ) addition Subtraction assignment ^ * / \ Mod + - =

Evaluate these expressions = 100 / 10 / 5 = 100 / 10 \ 5 = 100 \ 10 / 5 = Mod 5 = \ 5

Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 5 = 100 \ 10 / 5 = Mod 5 = \ 5

Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 5 = Mod 5 = \ 5

Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 550 = Mod 5 = \ 5

Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 550 = Mod 5100 = \ 5

Evaluate these expressions = 100 / 10 / 52 = 100 / 10 \ 52 = 100 \ 10 / 550 = Mod 5100 = \ 5102

Variables A variable is a string used to identify a memory location. The amount of memory is determined by the type of data that it will store. Typically, variable names need to be declared so the operating system can allocate sufficient space. Then values of the specified type can be assigned, i.e. stored in that location.

Variable names Must begin with a letter –Can include letters and numerals –Cannot include spaces Use names that are descriptive Capitalising convention –InterestRate, InitialCapital

Variables Local –Declared within a subprogram –Dim varName As dataType Global –Declared at the top of the code listing –Private varName As dataType

Data Types

The ASCII Character Set Hex ABCDEF Binary BSHTLF CR ESC !"#$%&'()*+,-./ :;<=>? PQRSTUVWXYZ[\]^_ `abcdefghijklmno pqrstuvwxyz{|}~DEL

Data Storage =255

Data Storage (2nd byte) = The largest Unsigned value that can be stored in 16 bits. How many different patterns?

Integer Storage To store integers, half the combinations are used to represent negative values. The range for Integer type variables is: -32,768 to The MSB is used to represent the sign. Which value of the sign bit (0 or 1) will represent a negative number?

2’s Complement Notation (examples in 8 bits to save space) The notation system that uses 1 to represent negative values. Fixed length notation system. Zero is the first non-negative value: The pattern immediately before zero is The largest value is stored as The smallest value is stored as

Arithmetic in 2’s Complement (remember it’s a fixed length system) = = = = 10 in 2’s complement in 2’s complement discard the carry bit

Long Integer Storage (4 bytes) High order bit (MSB) is worth 2 31 The number of different combinations =2 32 =4,294,967,296 Half are used for negative values, so the range is –2,147,483,648 to + 2,147,483,647

Fractions A radix separates the integer part from the fraction part of a number Columns to the right of the radix have negative powers of 2.

Fractions

Fractions ½¼⅛

Fractions ½¼⅛

Fractions ½¼⅛ ½+⅛

Fractions ½¼⅛ ½+⅛ 5⅝5⅝

Scientific Notation Very large and very small numbers are often represented such that their order of magnitude can be compared. The basic concept is an exponentional notation using powers of 10. a × 10 b Where b is an integer, and a is a real number such that: 1 ≤ |a| < 10

Scientific Notation An electron's mass is about kg. In scientific notation, this is written ×10 −31 kg. The Earth's mass is about 5,973,600,000,000,000,000,000,000 kg. In scientific notation, this is written ×10 24 kg.

E Notation To allow values like this to be expressed on calculators and early terminals × 10 b was replaced by Eb So ×10 −31 becomes E−31 And ×10 24 becomes E+24

E Notation The ‘a’ part of the number is called the mantissa or significand. The ‘Eb’ part is called the exponent. Since these numbers could also be negative they would typically have a sign as well.

Floating Point Storage In floating point the bit pattern is divided into 3 components: Sign – 1 bit (0 for +, 1 for -) Exponent – stored in Excess notation Mantissa – must begin with 1

Excess Notation (examples in 8 bits to save space) The notation system that uses 0 to represent negative values. Fixed length notation system. Zero is the first non-negative value: – The pattern immediately before zero is -1 – The largest value is stored as The smallest value is stored as

Mantissa Assumes a radix point immediately left of the first digit. The exponent will determine how far and in which directionto move the radix.

An example in 8 bits If the following pattern stores a floating point value, what is it?

An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components:

An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components: sign exponent mantissa

An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components: sign exponent mantissa

An example in 8 bits A sign bit of 0 means the number is…?

An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to …?

An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa …

An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa.1001 Put it all together …

An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa.1001 Put it all together … * 2 2

An example in 8 bits * 2 2 Multiplying a binary number by 2 shifts the bits left (move the radix to the right) one position. So the exponent tells us to shift the radix 2 positions right = 2¼

Normal Form The first bit of the mantissa must be 1 to prevent multiple representations of the same value. Otherwise…

Data Type Conversion