C1 Number systems.

Slides:



Advertisements
Similar presentations
A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s.
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Introduction to Number Representation F451 Year 10 Computing Binary Numbers Binary Numbers Sign/Magnitude Sign/Magnitude 2s Complement 2s Complement Binary.
Computers Organization & Assembly Language
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Data Representation S2. This unit covers how the computer represents- Numbers Text Graphics Control.
Binary Arithmetic & Data representation
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
COMPSCI 210 Semester Tutorial 1
Number Systems Spring Semester 2013Programming and Data Structure1.
ICS312 Set 1 Representation of Numbers and Characters.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
CPU Internal memory I/O interface circuit System bus
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Number Systems & Operations
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Introduction to Number Representation A451 GCSE Computing.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
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.
Advanced Binary b. describe and use two’s complement and sign and magnitude to represent negative integers; c. perform integer binary arithmetic, that.
Unit I From Fundamentals of Logic Design by Roth and Kinney.
Computer Representation of Information
Data Representation COE 308 Computer Architecture
Addition and Subtraction
Programming and Data Structure
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
Negative numbers: Week 10 Lesson 1
CHAPTER 9 COMPUTER ARITHMETIC - ALU
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Lesson Objectives Aims
CSCI 198: Lecture 4: Data Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Microprocessor Systems Design I
CHAPTER 1 : INTRODUCTION
CSCI 161: Lecture 4: Data Representation
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
Number Systems.
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
University of Gujrat Department of Computer Science
CS1010 Programming Methodology
Computer Organization and ASSEMBLY LANGUAGE
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
Data Representation Conversion 05/12/2018.
Dr. Clincy Professor of CS
Unit 18: Computational Thinking
Negatives, Addition, Subtraction
COMS 161 Introduction to Computing
Storing Negative Integers
ECE 331 – Digital System Design
23/04/2019 Data Representation Conversion.
Computer Architecture CST 250
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
Data Representation COE 308 Computer Architecture
Two’s Complement & Binary Arithmetic
Presentation transcript:

C1 Number systems

Negatives, Addition, Subtraction Binary Negatives, Addition, Subtraction

C1 Number systems The use and interpretation of number systems used in computer systems, including: units of digital data (bit, byte, kilobyte and multiples of these) binary binary coded decimal (BCD). The use of binary arithmetic (including BCD) to perform calculations: addition, subtraction, multiplication and division. The use of binary to represent negative and floating point numbers.

All used for different purposes within a CPU AQA CD-ROM Number Systems Binary Sign Magnitude Binary 2s Complement Binary All used for different purposes within a CPU

All computer processing is carried out digitally. Binary All computer processing is carried out digitally. Processor handles instructions as binary codes – zeros and ones. All data on a device is 0’s and 1’s.

Converting binary into positive denary integers Whole positive denary (base ten) numbers are converted into binary as follows: 135 from denary into binary 128 + 4 + 2 + 1 = 135 MSB LSB 128 64 32 16 8 4 2 1 1 1 1 1

Binary Addition Binary Subtraction

Binary Addition Sums In binary addition there are 5 possible sums: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0, carry 1 1 + 1 + 1 = 1, carry 1

Binary Addition Example 1 75 + 14 = 89 128 64 32 16 8 4 2 1 75= 14= Carry 89 1 1 1 1 1 1 1

Binary Addition Example 2 79 + 57 = 136 128 64 32 16 8 4 2 1 79= 57= Carry 136 1 1 1 1 1 1 1 1 1

Binary Addition Example 3 75 + 75 = 150 128 64 32 16 8 4 2 1 75= Carry 150 1 1 1 1 1 1 1 1

Binary Addition Example 4 215 + 138 = 353 (101100001) (exercise 3c Page 97) 128 64 32 16 8 4 2 1 215= 138= 353 1 1 1 Overflow 1 1 1 1 1

Binary Subtraction CPUs can’t subtract, they can only add! 75-14=61 The same as… 75+(-14)=61 Positive + Negative = Negative To do this we need 2s Complement -128 64 32 16 8 4 2 1

Storing Negative Integers Another method is 2s Complement -75 64 32 16 8 4 2 1 128 -128 1 1 1 1 1 -128+32+16+4+1=-75

2s Complement Conversion -117 Stage 1 : work out 117 in binary 128 64 32 16 8 4 2 1 Stage 2 : Reverse the 0’s and 1’s -128 64 32 16 8 4 2 1 1 Stage 3 : Plus 1

Storing Negative Integers 1 method is Sign/Magnitude 75 -75 MSB 64 32 16 8 4 2 1 +/- 128 1 1 1 1 1 1 is a Negative, 0 is a Positive

64 32 16 8 4 2 1 +/- 1 1 1 1 Sign Value or Magnitude Sign/Magnitude This method has some limitations 2 types of data in the same value (MSB is a sign) Makes calculations difficult by losing 1 bit 127 maximum number 64 32 16 8 4 2 1 +/- 1 1 1 1 Sign Value or Magnitude

Binary Subtraction Example 1 75-14=61 75+(-14)=61 -128 64 32 16 8 4 2 1 75= -14= 61 1 1 1 1 1 1 1 1

Binary Subtraction Example 2 91-18=73 91+(-18)=73 -128 64 32 16 8 4 2 1 91= -18= 73 1 1 1 1 1 1 1 1 1 1

This is the same as an // operation in Python Logical Shifts A left or right logical shift can be performed on a binary number as a method of multiplication or integer division. This is the same as an // operation in Python We can perform multiplications or integer divisions in powers of 2

Left Logical Shifts Example 1 128 64 32 16 8 4 2 1 Take this byte – 104 in denary Shift it left by 1 128 64 32 16 8 4 2 1 11010000 – 208 in denary (104x2) 2**1 is 2

Left Logical Shifts Example 2 128 64 32 16 8 4 2 1 Take this byte – 104 in denary Shift it left by 2 256 128 64 32 16 8 4 2 1 110100000 – 416 in denary (104x4) 2**2 is 4

Left Logical Shifts Example 3 (activity 5a page 102) 128 64 32 16 8 4 2 1 Take this byte – 58 in denary Shift it left by 3 - 2**3 (8) 256 128 64 32 16 8 4 2 1 111010000 – 464 in denary (58x8)

Right Logical Shifts Example 1 128 64 32 16 8 4 2 1 Take this byte – 185 in denary Shift it right by 1 128 64 32 16 8 4 2 1 01011100 – 92 in denary (185//2) Integer Division 2**1 is 2

Right Logical Shifts Example 3 Activity 5b Page 102 AQA CD-ROM Right Logical Shifts Example 3 Activity 5b Page 102 128 64 32 16 8 4 2 1 Take this byte – 157 in denary Shift it right by 4 128 64 32 16 8 4 2 1 00001001 – 9 in denary (157//16) Integer Division 2**4 is 16

Left arithmetic shift – The MSB remains untouched Arithmetic Shifts A left or right arithmetic shift can be performed on a 2s complement binary number as a method of multiplication or integer division. Left arithmetic shift – The MSB remains untouched Right arithmetic shift – use a copy of the MSB as the replacement bits

Left Arithmetic Shifts Example 1 (page 102) -128 64 32 16 8 4 2 1 Take this byte -36 in denary (-128+64+16+8+4) Shift it 1 place left arithmetic shift -128 64 32 16 8 4 2 1 10111000 – -72 (-36x2) -128+32+16+8

Right Arithmetic Shifts Example 1 (page 103) -128 64 32 16 8 4 2 1 Take this byte -72 in denary (-128+32+16+8) Shift it 2 places right arithmetic shift -128 64 32 16 8 4 2 1 11101110 – -18 (-72//4) (2**2=4) -128+64+32+8+4+2

Representing characters There are two main coding systems that provide conversions of keyboard characters into binary: ASCII UNICODE

ASCII ASCII stands for the American Standard Code for Information Interchange. It has been adopted as the industry standard way of representing English language keyboard characters as binary codes. Every keyboard character is given a corresponding binary code. ASCII uses an 7-bit code to provide 128 characters.

UNICODE UNICODE is the new standard to emerge that is replacing ASCII. Uses 16 bits per character It is designed to cover more of the characters that are found in languages across the world. It has become important due to the increased use of the Internet, as more data is being passed around globally.