CS334: Number Systems Lab 1.

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

Representing Numbers: Integers
King Fahd University of Petroleum and Minerals
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Assembly Language and Computer Architecture Using C++ and Java
M68K Assembly Language Programming Bob Britton Chapter 4 Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Digital Fundamentals Floyd Chapter 2 Tenth Edition
© 2010 Kettering University, All rights reserved..
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Logic and Digital System Design - CS 303
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Number systems, Operations, and Codes
The Hexadecimal Number System and Memory Addressing ISAT 121.
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Operations on Bits Arithmetic Operations Logic Operations
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Chapter 1: Binary Systems
Introduction to Digital Electronics Lecture 2: Number Systems.
CS334: Number Systems&& Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
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.
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
Lecture 4: Digital Systems & Binary Numbers (4)
Cosc 2150: Computer Organization
Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations
NUMBER SYSTEMS.
Lec 3: Data Representation
Data Representations and Computer Arithmetic
Digital Systems and Number Systems
Data Representation Binary Numbers Binary Addition
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
Digital Arithmetic Wen-Hung Liao, Ph.D..
Data Representation in Computer Systems
Digital Systems and Binary Numbers
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Addition and Substraction
Wakerly Section 2.4 and further
Introduction to IT By: Muhammed s. anwar.
Data Representation Data Types Complements Fixed Point Representation
Chapter One: Introduction
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Numbering Systems and Arithmetic operations on Hex, binary, and octal
Digital Systems and Binary Numbers
CS334: Memory _ Mars simulator Lab 4(part2-2)
Homework Homework Continue Reading K&R Chapter 2 Questions?
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
CS334: MIPS language _Mars simulator Lab 2_1
Chapter3 Fixed Point Representation
Chapter 1 (Part c) Digital Systems and Binary Numbers
CHAPTER 69 NUMBER SYSTEMS AND CODES
Presentation transcript:

CS334: Number Systems Lab 1

General Instructions Quizzes/Participation/Absence 5% Logisim/MIPS Programming 5% CPU Design Project 10% Email: ebtesam.jaber@hotmail.com Website: http://ebtesamal-etowi.weebly.com Ins.Ebtesam AL-Etowi

Contents: Review Exercises Ins.Ebtesam AL-Etowi

1-1 Introduction The decimal number system uses 10 different digits (symbols), (0,1, 2, 3, 4, 5, 6 ,7 ,8 ,9). The binary number system uses only two digits, 0 and 1, which are represented by two different voltage levels within a computer’s electrical circuits. Any value can be represented in either number system as long as there is no limit on the number of digits we can use. In the case of the MIPS architecture, values in registers and in memory locations are limited to 32 bits. The range of values that can be stored in a register or a memory location is -2,147,483,648 to +2,147,483,647 (Assuming the use of the two’s complement number system). Ins.Ebtesam AL-Etowi

(2) binary (10) (8) decimal octal (16) hexadecimal Ins.Ebtesam AL-Etowi

1-2Positional Notation The polynomial representation of 2056 in the base ten number system is:   Therefore, 2056 in the base eight number system is equivalent to 1070 in the base ten number system Ins.Ebtesam AL-Etowi

1-3Converting Binary Numbers to Decimal Numbers 2 1 3 4 5 6 7 8 9 10 16 32 64 128 256 512 1024 Therefore, the binary number 011010 is equivalent to 26 in the decimal number system. 1-4 Detecting if a Binary Number is Odd or Even . If the right most digit in a binary number is a one, then the number is odd. For example 00011100 is an even number, which is the value 28 in the decimal number system. The value 0001001 is an odd number, specifically the value 9 in decimal. Ins.Ebtesam AL-Etowi

3x4 =Sift by tow bit to left 1-5 Multiplication by Constants that are a Power of Two Another important feature of the binary number system is that multiplication by two (2) may be accomplished by shifting the number left one bit. Multiplication by four (4) can be accomplished by shifting left two bits. 0011 0100 x 0000 + 0000 0011 0000 1100 3x4 =Sift by tow bit to left Ins.Ebtesam AL-Etowi

1-6 The Double and Add Method A quick and efficient method for converting binary numbers to decimal involves visually scanning the binary number from left to right, starting with the left most 1. As you visually scan to the right, double the value accumulated so far, and if the next digit to the right is a 1, add 1 to your accumulating sum. Ins.Ebtesam AL-Etowi

1-7Converting Decimal Numbers to Binary Numbers Ins.Ebtesam AL-Etowi

1-8 The Two’s Complement Number System The major benefit of the two’s complement number system is that it simplifies the design of the hardware to perform addition and subtraction In the two’s complement number system, all numbers that have a one in the most significant digit (MSD) are negative numbers. 00000001 two’s complement would be= 11111111 Ins.Ebtesam AL-Etowi

1-9The Two’s Complement Operation When we take the two’s complement of a number, the result will be the negative of the value we started with. One method to find the two’s complement of any number is to complement all of the digits in the binary representation and then add one to this new binary value. 00011010 Complement every Bit 11100101 Add one +1 This is the value minus 26 11100110 1-10 A Shortcut for Finding the Two’s Complement of any Number Ins.Ebtesam AL-Etowi

1-11 Sign Extension For example, the value 6 represented as an 8-bit binary number is: “00000110”, and the value 6 as a 32-bit binary number is “00000000000000000000000000000110”. The same rule applies for negative numbers. For example the value minus 6 represented as an 8-bit binary number is: 11111010, and the value -6 as a 32-bit binary number is 11111111111111111111111111111010 Ins.Ebtesam AL-Etowi

1-12Binary Addition 1-13 Binary Subtraction Ins.Ebtesam AL-Etowi Decimal 29 00011101 14 00001110 Sum 43 00101011 1-13 Binary Subtraction Minuend is 35 00100011 00100011 Subtrahend is 26 -00011010 Take two’s complement and add +11100110 00001001 Ins.Ebtesam AL-Etowi

1- 14 Overflow Detection Ins.Ebtesam AL-Etowi

1-15 Hexadecimal Numbers symbols used as digits in hexadecimal numbers are (0,1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). A convention has been adopted to identify a hexadecimal number. The two characters “0x” always precede a hexadecimal number. Decimal Binary Hexadecimal 0000 0x0 1 0001 0x1 2 0010 0x2 3 0011 0x3 4 0100 0x4 5 0101 0x5 6 0110 0x6 7 0111 0x7 8 1000 0x8 9 1001 0x9 10 1010 0xA 11 1011 0xB 12 1100 0xC 13 1101 0xD 14 1110 0xE 15 1111 0xF For example, 0xA2F0 in hexadecimal corresponds to 1010001011110000 in binary. Ins.Ebtesam AL-Etowi

Exercises Convert the decimal number 32 to an 8-bit binary number Using the double and add method convert 00010101 to a decimal number. Explain why the Least Significant digit of a binary number indicates if the number is odd or even Convert the binary number 00010101 to a hexadecimal number. Convert the hexadecimal number 0x15 to a decimal number. Convert the decimal number -32 to an 8-bit two’s complement binary number. You are given the following two 8-bit binary numbers in the two’s complement number system. What values do they represent in decimal? X = 10010100 =----------------- Y = 00101100 = ------------- Ins.Ebtesam AL-Etowi

Convert the base 5 number 204 to decimal Assuming the use of the two’s complement number system find the equivalent decimal values for the following 8-bit binary numbers: (a) 10000001 Convert the base 5 number 204 to decimal You are given the following two numbers in two’s complement representation. Perform the binary addition. Did signed overflow occur? determined whether or not overflow occurred. 01101110 00011010 Convert the base 10 number 81 to a base 9 number Sign extend the 2 digit hex number 0x88 to a 4 digit hex number. 0x . Ins.Ebtesam AL-Etowi

You are given the following two numbers in two’s complement representation. Perform the binary subtraction. Did signed overflow occur? determined whether or not overflow occurred. 11101000 -00010011 Ins.Ebtesam AL-Etowi

H.W Ins.Ebtesam AL-Etowi 16 Bit Binary Hexadecimal Decimal 1111111100111100 0xFF88 -128 1111111111111010 0x0011 -25 Ins.Ebtesam AL-Etowi