Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS334: Number Systems Lab 1.

Similar presentations


Presentation on theme: "CS334: Number Systems Lab 1."— Presentation transcript:

1 CS334: Number Systems Lab 1

2 General Instructions Quizzes/Participation/Absence 5%
Logisim/MIPS Programming 5% CPU Design Project 10% Website: Ins.Ebtesam AL-Etowi

3 Contents: Review Exercises Ins.Ebtesam AL-Etowi

4 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

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

6 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

7 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 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 is an even number, which is the value 28 in the decimal number system. The value is an odd number, specifically the value 9 in decimal. Ins.Ebtesam AL-Etowi

8 3x4 =Sift by tow bit to left
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

9 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

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

11 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. two’s complement would be= Ins.Ebtesam AL-Etowi

12 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. Complement every Bit Add one This is the value minus 1-10 A Shortcut for Finding the Two’s Complement of any Number Ins.Ebtesam AL-Etowi

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

14 1-12Binary Addition 1-13 Binary Subtraction Ins.Ebtesam AL-Etowi
Decimal Sum 1-13 Binary Subtraction Minuend is Subtrahend is Take two’s complement and add Ins.Ebtesam AL-Etowi

15 1- 14 Overflow Detection Ins.Ebtesam AL-Etowi

16 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 in binary. Ins.Ebtesam AL-Etowi

17 Exercises Convert the decimal number 32 to an 8-bit binary number
Using the double and add method convert 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 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 = = Y = = Ins.Ebtesam AL-Etowi

18 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) 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. 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

19 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. Ins.Ebtesam AL-Etowi

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


Download ppt "CS334: Number Systems Lab 1."

Similar presentations


Ads by Google