COMPUTING FUNDAMENTALS Instructor: Romana Farhan Lecture # 02 Romana.farhan@uettaxila.edu.pk
How do computers represent data? Number systems Binary number system Binary Arithmetic
the binary number system. CPU consists of several million tiny electronic switches called transistors, that can be turned on or off. Computers know two distinct physical states Switch is on or off Since these switches only have two states, it makes sense for a computer to perform its computations with a number system that only has two digits. the binary number system.
Several different number systems exist Used by humans to count A manner of counting Several different number systems exist Decimal number system Used by humans to count Contains ten distinct digits (0-9) Digits combine to make larger numbers
Used by computers to count Binary number system Used by computers to count Two distinct digits, 0 and 1 corresponding to off or on state of switch. 0 and 1 combine to make numbers With only these two digits, a computer can perform all the arithmetic that we can with ten digits Goal of our study is to know Converting between binary and decimal, Performing binary arithmetic,
of any number by system is of digits in the the number The base determined system. of any number by system is of digits in the the number For example Binary is a base 2 number system Decimal is a base 10 number system Octal ????? Hexadecimal ????? Distinguish between various number systems by putting a small subscript after the number to indicate the base.
understand the relationship between the digits of a given number, For example ◦ 462.1510 ◦ 110.112 we need to understand the relationship between the digits of a given number, the position of those digits, and the base of the number system. Let's take another look at our example number in the decimal system.
Generalized formula
by both the number and its position. In decimal system value of number is defined by both the number and its position. Most significant bit/digit (MSB,MSD) The digit in a number which can affect the number Significantly It is the non zero digit of a number that is in the farthest left. The least significant bit/ digit (LSB, LSD) It is the digit in a number that has the least effect on that number.
Any changes in the LSD will have minimal effect on the value. It is the non zero digit of a number that is farthest right. For example
To convert a decimal number to a binary number, The decimal number is successively divided by 2. Follow the following steps Divide the decimal number by 2 and note the remainder. Divide the quotient you got from the previous division once again by 2 and note the remainder. For each step, the division results in a remainder of 1 or 0.
Repeat step 2 until the quotient becomes 1. The binary number is obtained by ordering the 1s and 0s obtained as remainders from bottom to top.
To convert the fractional part of the decimal number to a binary number, the part is repeatedly multiplied by 2. Follow the following steps fractional The decimal fraction is multiplied by 2. the integer part, which is noted i.e. either 0 or 1 The fractional part of the previous product is multiplied by 2. Repeat the first step until the fraction repeats or terminates. The integer part which is obtained as a result forms a string of 0s and 1s which becomes the binary equivalent of the decimal fraction.
4. to obtain the binary number of the equivalent fractional, you need to consider the integer part from top to bottom.
167 0.875 21.625
number, perform the following steps. To convert a binary number to a decimal number, perform the following steps. 1. Start with the rightmost digit and multiply that digit with 20. Here 2 represents the base of the number position, system and 0 represents the which is the rightmost digit digit whose position always starts with 0. Continue working from right to left, and multiply each digit with an increasing power of 2 Repeat step 2 until all the digits have been multiplied Add the result of each worked power of 2 for a final answer
decimal number in the same manner but Fractional binary number can converted to decimal number in the same manner but The exponent are powers of two with negative values for digits on the right side of the binary point.
1001110 0.10111
Binary Addition Binary Subtraction Binary Division
1 + 1 10 Basic four rules of addition 1. First, we apply Rule 4 to find the sum of the first two 1s. 1 + 1 10
answer to the second column. 10 + 1 11 to find the 2. Next, we take the previous result of 102 and add the final 1 to it. Notice that we use Rule 2 (0 + 1 = 1) to find the answer to the first column, 3. We use Rule 3 (1 + 0 = 1) answer to the second column. 10 + 1 11 to find the
4. Now we have derived another rule for binary arithmetic 4. Now we have derived another rule for binary arithmetic. The sum of three 1s in binary is 112. 1 + 1 11
Add 1112, 1102, 11012, 1012, and 11102
how to add the binary numbers 110.012 and 1.0112 Addition is same as addition of binary integers, we need to take care of radix point while adding fractional part. Example how to add the binary numbers 110.012 and 1.0112 1. First, we align the two numbers so that the radix point of each number is located column. 110.01 + 1.011 in the same 2. Next, we fill in the blank spaces with 0s and add the two numbers together. 110.010 + 001.011
The first column adds to 1. 110.010 + 001.011 1 The second column adds to 102, so we write a 0 below it and carry a 1 to the next 1 column 110.010 + 001.011 01
5. All of the remaining columns add to 1, so we write 1 below them. 1 110.010 + 001.011 111.101 4. This gives us a final answer of 111.1012.
Add 10.101+1.111
2(10) 3 0 - 6 2 4 The basic rules for binary subtraction are Consider the problem of subtracting 12 from 102.
borrow a 1 from the next column. To compute the first column, we need to borrow a 1 from the next column. Recall that two 1s generated a carry in addition. If we reverse this process, we can borrow a 1 from the second column. Once we borrow from the second column,we cross out the 1 and write 0 above it to show this column is now empty. 10 -1
Since we must borrow a 1 from the next After cleaning up our work, we can see that the first column of our answer is identical to Rule 4. Since we must borrow a 1 from the next column, 0 - 1 = 1. 10 - 1 1
Subtract 101101 − 100111 1011011 − 10010 1000101 − 101100 100010110 − 1111010 1011.101-11.011 When the binary fraction 11101 is subtracted from the binary fraction 101101.101 what is the correct result?
we multiply by is either Binary multiplication uses the same technique as decimal multiplication. Binary multiplication is much easier because each digit one. Example we multiply by is either 1102 multiplicand 10 2multiplier zero or multiplying 1102 by 102 1. First, we note that 1102 is our multiplicand and 102 is our multiplier.
next digit of our multiplier which is 1. 2. We begin by multiplying 1102 by the rightmost digit of our multiplier which is 0. Any number times zero is zero, so we just write zeros below. 110 x 10 000 3. Now we multiply the multiplicand by the next digit of our multiplier which is 1. To perform this multiplication, we just need to copy the multiplicand and shift it one column to the left as we do in decimal multiplication.
we add our results together. The 110 x 10 000 110 we add our results together. The 4. Now product of our multiplication is 11002 110 x 10 000 110 1100
Ignore radix point, do not align them Multiply numbers as whole numbers Starting from right of the product, separate as many places as there are in the two numbers together
10.01*1.01 1001 *101 --------- 0000 ------------- 101101 Now put the radix point, together binary fractions have four decimal places. starting from right separate the four decimal places 10.1101
remember some important rules: the remainder is less than the divisor, When doing binary division, we need to remember some important rules: When the remainder is greater than or equal to the divisor, write a 1 in the quotient and subtract. When the remainder is less than the divisor, write a 0 in the quotient and add another digit from the dividend.
mark a radix point in the dividend and append a zero. If all the digits of the dividend have been considered and there is still a remainder, mark a radix point in the dividend and append a zero. Remember that some fractions do not have an exact representation in binary, so not all division problems will terminate.
1. 10|11 1 2. 10|11 10 3. 1. 10|11.0
1. 10|11.0 10 1.1
Divisor must be a whole number, if it is not, then we will multiply it so that it becomes one. Multiply the dividend by the same power Example 10.1101/1.01
Divide 1000012 by 1102 10.11101/11.011
therefore data and numbers must be represented in a numeral format. Digital computers respond to numbers, therefore data and numbers must be represented in a numeral format. The ON/OFF positions of electronic switches in a digital computers correspond to binary digits 0 or 1. Inter-conversion of numbers from one number system into other becomes important for computation and data processing in digital computers.
required to perform addition, division and multiplication. In digital computers very few rules are required to perform addition, division and multiplication. subtraction,
Convert to decimal i. 10101001 ii. 11100111 iii. 01101110 iv. 01101111
45 i. 69 ii. 1066 iii. 99 iv. 1939 v. 998
DIVIDE 11011001/1011 101010111/11001 1110101011.110101/10110
Multiply 1101 * 1101 1011* 1001 100011 * 1100011 101010111 * 11001 1110101011.110101 * 10110