Beruflich Dokumente
Kultur Dokumente
Announcements
Lab 12 starts from Thursday, 3rd November. Monday sections will do lab on 5th November (Saturday) instead y ( y) of 7th November (Idul Zuha) Lab exam in the week of 14th to 18th November Labs 11 and 12 will not be pre-announced to give you practice End-sem exam is on 25th November, 8:00 AM End sem Copies can be seen on 28th afternoon.
Lec-35
Recap
Program in multiple source files External variables Static variables
Lec-35
If static is not used, and it is recursive function, then every call would have needed such a large memory area, and there th was no way to access what previous call to the t h t i ll t th function was doing.
Lec-35
Lec-35
Integer Representation
We represent integers as binary numbers
since computer memory can only store 0 or 1. For example: 56 will be stored as 00111000
Ones Complement
In 1s complement representation
Positive numbers are stored as mentioned previously
First bit is 0 Other bits store the binary representation of the number
Example:
+56 is 00111000 -56 is 11000111
Lec-35 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 9
Ones complement
Problems with 1 s complement 1s
addition always requires an extra carry operation multiplication requires that we convert the negative number to positive number, carry out multiplication, and then again convert the positive number to negative number (if needed) Hence inefficient computation A minor issue: there are two representations for 0
all 0s all 1s
Lec-35 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 10
Twos Complement
Positive numbers are stored as usual (as in 1s complement) To represent negative number
First find its 1s complement representation Add 1 to the 1s complement representation Example: To store -56
First consider 56, which is: 00111000 Take 1s complement: 11000111 Add 1 to it: 11001000
Lec-35
12
In normalized form, the integer part of the fraction is exactly 1 The above fraction in normalized form will be:
1.10011 X 210111
Now, we can save one bit by not storing the integer part of the fraction, since it is always 1.
Lec-35 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 14
Lec-35
16
Lec-35
17
Lec-35
18
Lec-35
19
10
Any Questions?
Lec-35
20
11