Presentation is loading. Please wait.

Presentation is loading. Please wait.

Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.

Similar presentations


Presentation on theme: "Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems."— Presentation transcript:

1 Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems

2 Introduction (1) A number system is a well defined structured way of representing or expressing numbers as a combination of the elements of a finite set of mathematical symbols (i.e., digits). The functions of a number system are: – Represent a useful set of numbers. For example, all integers or rational numbers. – Give each number a standard representation. There are two major types of number systems. These are, 1. Positional number systems 2. Non positional number system

3 Introduction (2) 1. Positional number systems This uses the same symbol for different orders of magnitude This greatly simplifies arithmetic. Eg: Decimal, binary & hexadecimal number systems. 2. Non positional number system It combines digits to signify their sums or their differences. The sum/difference represents a number. Eg: Roman number system where MMXI represents 2011, IX represents 9. In this section we will consider Decimal, binary & hexadecimal number systems.

4 General Representation of a Number System In general, the number a 3 a 2 a 1 a 0 in a base b number system represents the following number: a 3 a 2 a 1 a 0 = a 3 * b 3 + a 2 * b 2 + a 1 * b 1 + a 0 * b 0 Base is the number of unique digits including zero. Eg: Decimal number system has 10 digits (0, 1 … 9). Therefore, the base is 10. Binary number system has 2 digits (0, 1). Therefore, the base is 2. Hexadecimal number system has 16 digits (0, F). Therefore, the base is 16.

5 Digits used for number systems

6 Counting under these number systems

7 Binary number system The binary number system represents numerical values using two symbols, 0 and 1. This is a positional number system. The binary system has a base of 2 with a radix of 2. In general a number could be represented as a binary number as follows, a n …a 3 a 2 a 1 a 0 = a n * 2 n +a 3 * 2 3 + a 2 * 2 2 + a 1 * 2 1 + a 0 * 2 0 These numbers are straightforward to implement, hence used in digital circuitry, logic gates and in almost all modern computers. 1 and 0 in binary numbers correspond to the ON and OFF in digital systems.

8 Most Significant Bit & Least Significant Bit 10011100 10011100 Most Significant Bit (MSB) Least Significant Bit (LSB) Indicates the sign bit in some cases Indicates whether the number is odd or even

9 Decimal range covered by some commonly used bit values Bit valuesDecimal Range 40-15 80-255 120-4095 160-65,535 320-4,294,967,296 640-1.84467441 × 10 19

10 Binary to Decimal Conversion Convert (1101) 2 to a decimal number. Convert 8 bit (1101 1000) 2 to a decimal number. What is the MSB and LSB of the number?

11 Decimal to Binary Conversion – Power Method Step 1: Find the highest whole power of 2 contained in the decimal number. Step 2: Subtract the highest whole power of 2 from the decimal number. Step 3: Repeat Step 1 with the remainder. Step 4: Construct the binary number by placing a 1 in the position which corresponds to power value of the highest whole power of 2.

12 Decimal to Binary Conversion – Remainder Method Step 1: Divide the decimal number by the base (in the case of binary, divide by 2). Step 2: Indicate the remainder to the right. Step 3: Continue dividing into each quotient (and indicating the remainder) until the divide operation produces a zero quotient.

13 Hexadecimal Number System (1) Hexadecimal number system is a human-friendly binary number representation. Using this method it is possible to give the numbers a much compact representation. Each hexadecimal digit represents 4-bits. An 8-bit binary number can be represented by two hexadecimal digits. Eg: (1111 1110) 2 can be represented by FE 16. (0010 0011) 2 can be represented by 23 16. Both the power method and remainder method applies to hexadecimal number system.

14 Hexadecimal Number System (2) Ex: Convert ABCDEF in hexadecimal into a decimal number. Convert 1000 10 into hexadecimal using the power method and the remainder method.

15 Decimal HexadecimalBinary

16 Representing Negative Numbers in Binary There are different techniques used to represent negative numbers in binary. These are, – Signed magnitude method – One's complement method – Two's complement method

17 Signed magnitude method This approach is directly similar to the most common way of constructing a sign. – i.e. placing ‘+’ or ‘-’ in front of a number According to this method the MSB indicates the sign of the number. – 0 indicates +ve & 1 indicates –ve Eg: 8-bit, 00001100 2 = +12 10. 10001100 2 = -12 10. Some of the early computers (eg. IBM 7090) used this method.

18 Signed magnitude method In signed magnitude, the left-most bit is not actually part of the number, but is just the equivalent of a + or - sign. Arithmetic operations Eg: 8-bit, 00001100 2 = +12 10 10001100 2 = -12 10. 0000 1100 2 + 1000 1100 2 = 1001 1000 2 Answer = -24 10  Is this correct? Can we use this for arithmetic operations? NO

19 One's complement method (1) Positive numbers are represented as a regular binary numbers. Negative numbers are represented differently. Under this method in order to negate a number, it replaces all zeros with ones, and ones with zeros i.e. take the compliment. Eg: +12 would be 0000 1100 2 & -12 would be 1111 0011 2. As in sign magnitude MSB indicates the sign (‘0’ is +ve, ‘1’ is -ve).

20 One's complement method (2) Representation of 4-bit binary in one’s compliment method. One drawback of this method is that it has two different representations of zero.

21 Two's complement method (1) Begin with the number in one's complement. Add 1 if the number is negative. Eg: – 12 10 would be represented as 0000 1100 2, and -12 10 as 1111 0100 2. – To verify this, let's subtract 1 from 1111 0100 2, to get 1111 0011 2. – If we flip the bits, we get 0000 1100, or 12 in decimal.

22 Converting Decimal to n-bit Binary using Two's complement method For Positive Numbers: 1.Convert the magnitude of the number to binary. 2.Add zeros to make the binary number an n-bit number. Ex: If your number consists of 5 bits but the goal is to get a number consisting 8-bits, pad the 5-bit binary number by adding three zeros to the left. For Negative Numbers: 1.Convert the magnitude of the number to binary. 2.Add zeros to the left to make the binary number to have n digits. 3.Complement the number (i.e., invert the bits). 4.Add 1 to the inverted binary number to get the n-bit 2's complement notation.

23 Converting n-bit 2's Complement Binary to Decimal 1. Look at the leftmost bit to determine whether the number is positive or negative. If the leftmost bit is 0, the number is positive. If the leftmost bit is 1, the number is negative. 2. If positive, convert the number from binary to decimal. 3. If negative, determine the magnitude by: – Invert the bits of the binary number. – Add 1 to the inverted number. – Convert the result of the addition operation to decimal to get the magnitude of the corresponding decimal number. – The actual decimal number is the negative of this number.

24 4-bit Binary in 2's Complement Method


Download ppt "Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems."

Similar presentations


Ads by Google