Subtitles section Play video Print subtitles hello everyone i'd like to welcome you all to this fall's this terms instance of this course is a fish way either 15 213 from computer science or 18 213 from electrical and computer engineering but a large number of people enrolled in this course are in one called 513 which is for graduate students and to be totally honest you're not supposed to be here because you supposed to watch the videos the lectures by video later but we're not checking any cards so i don't really know who you are Oh anyways this course is a as you can see a very popular course on campus we have over 700 700 600 shouldn't exaggerate students on campus and rolled in one of those three versions of the course which if you think about a university of the size of CMU it's like about five percent of the total student population so we're very glad to have you here in this game is too high think we overdid the game try that that's better so my name is Randy Bryant and my co-instructor is Dave O'Halloran and those names might be familiar if you have been to the bookstore because the book was written by us and we actually wrote this book of we started to 13 is a course in 1998 are and I know that your children them and all that stuff but up out of response for our new type of course that you'll see today that sort of gives people are in depth understanding of systems but more from a high level or programmers perspective and we'll talk some about the philosophy of the course later so this book as you see are just came out its third edition last March and that's the required text for the course and there is nothing you can do to avoid buying that book and it's not because we're greedy actually we take the money we get from royalty for students in this course or any CMU course and we donate it to CMU so we're not actually making any money out of you buying the book but it's a simple reality that the new version is different than the old we expect you to be using the new version there are no electronic copies there are no pirated version so you basically have to buy the book but and I don't really apologize for that because i know you or your parents or somebody's paying a lot of money for you to be here and so the price of the book is really a relatively small amount relative to that and up this course by the way is is not some courses there's oh yeah this book you might want to look at it once in awhile but actually the course has nothing to do with it this course the book and the course are one they're very tied together there'll be parts of the book that we don't go into all the details that are in the book sometimes but we expect you to be able to figure it out and so really the course in the book are tied together and they very much the the progress the course the topics covered how it's covered everything about it is consistent with the book and we wrote the book because of the course think of them as course notes so and the reason why we are teaching this term by the way we haven't talked together in several years but because this is the first roll out of this book and not only is it being used here but it's actually used by about 250 schools around the world and many of those people are also going through the same of activities of teaching for from this new edition for the first time and so we wanted to make sure all the material for the course was sort of put in order and thanks because other universities and other colleges use this material of the supporting material we've developed so that's the course and today is the first election we're sort of doing a tag team here I'll talk the high-level what the course is about what the main themes are and today we'll talk more about the logistics so we refer that the saying we have one of the very first time I type the number of this course into a text editor i realized i've typed those five digits many times in my career because it's the zip code of CMU 1521 three so that's where we come up with the same so arm there is a few things about this course for the most part you know and your normal undergraduate curriculum when you learn programming you've been very much separated from the realities of the Machine you you just think about code just you put some text into some little box somehow and outcomes of behavior that it hopefully is what you intended the program to do the purpose of this course is to give you enough understanding of what that box is doing when it executes your code and through that to help you I'll become better at what you're trying to do so some of the outcomes is there's really two types of outcomes from this course one is that if this is the only systems course you ever taken your whole life you will get useful material from it you will learn tools tricks methods that will help you if you ever are involved in software development a large-scale software engineering projects systems hardware design any aspect of of computer technology this will help you be better at what you do you'll understand what programs do how they work what the machines that support them do why sometimes they work really well and why sometimes they don't work so well oh it also is intended as a sort of stepping stone into a whole number of other courses at CMU that will give you more in-depth understanding of computer technology but are sort of specialized by topical area whether it's computer networking or operating systems or embedded systems where you'll take the sort of ideas from this course and be able to then learn it as somewhat narrower but deeper sense what's really going on and so it really is trying to serve those two goals of making you more effective giving you useful ideas and tools right away but also preparing you for later courses so one way we talk about this is sort of what why what kind of stuff will you learn from this course is to go through a series of what we call great realities places where sort of computers meetup real-life computers get meet up against your expectations and maybe they're not quite the same so one of them is in the first part of the course is going to take a fairly detailed look at how numbers are represented in computers and you'll learn some things that are on one hand surprising and another your hand will start to make sense when you understand it better so are a simple case is for numbers i don't know when it was but it was probably in about eight grade algebra that I've learned that if you square a number it will be at least 0 if it's not an imaginary number so a either an integer or a real number you'd expect to square and it to be a positive value or perhaps 0 right arm and that's actually generally true with floats a representation of floating-point numbers but with integers are hints you know the the computer representation of integers it's not so clear so for example a few square 40,000 on most computers then you'll get $PERCENT of whatever that should be as you'd expect but what if you square 50,000 so you could do this in your head but actually built into this laptop is a computer so i'm going to go ahead and use it just sighs and use the to all which on unix systems is called know what's going on before we are on our linux systems is called GDB but on a macintosh OS X it's called lld but they're pretty much the same program you will get to know this program really really well this term so like i said if you square 40,000 you'll get what you'd expect but let's change this to 50,000 and you get a very peculiar number that doesn't look anything like you'd expect 50,000 squared to be and in fact it's negative and so that might just seem like well there must be a mistake or something know that that's just the way it is because of this computer is expecting numbers to be represented as 32-bit values and the bit pattern that you get when you do this multiplication happens to be the representation of a negative number so that's a an example of where your normal expectations about integer arithmetic may or may not hold up on the other hand there are some places like if i try to do the same thing multiplying 300 by forward by 500 x 600 then all of a sudden i also get a number that clearly is not what you'd expect because the same thing has happened I've gotten an overflow it happens that it's overflowed to value that's positive not negative but it still is obviously not the integer product of those four numbers on the other hand one thing you'll find is even though this arithmetic is not a normal sort of integer arithmetic it actually has some well-behaved properties so for example if you look at it what i've done is i just moved the 300 around from the beginning of the product the end of the product and so now if you think about how associate ility and community works basically multiplying these four numbers in a different order but what you see is you get the same funny-looking result uh no matter how you do it so what you can say from this is integer arithmetic is commutative and associative sobes some of the conventional mathematical properties it just isn't what you'd expect it to be it's not a up normal sort of mathematical integer arithmetic so the cartoon here shows an example that similar possibility we get to it oh I guess it comes at the end up so that the next question is is edition associative right can you order that the numbers and then you probably might have figured both it in the integer arithmetic even though as this potential for overflow it is associative and it's a community of two but four floats it's not really quite the same because the range of values you can get in floating point or so extreme that some numbers kind of disappear on you so the example I'll show without having to use a computer to do it is if you take a big number and subtract it from itself you'll get zero so if you add that to 3.14 you'll get 3.14 but if you take those two numbers and you reorder the how you combine them so that that 3.14 compared to minus ten to the twentieth is so insignificant that result gets turned into a minus ten to the twentieth and you add that to one ten to the twentieth and you end up with zero so it's not associative and so what you see is the both these numbers systems have some peculiarities and it all comes down to the fact that they use finite representations of things that are potentially infinite and their expands and so there's some compromises in how those work and what the compromises you can overflow an integer and and run out of room and in floating point numbers you have roundoff problems where you should drop the digits that are significant you can also over floating point but the more common problem is round of so this is shown in this cartoon this idea of overflow of somebody counting sheep which in the u.s. is are in english language at least a way to fall asleep and when he or she goes from 30 2767 and then increment set by one gets minus-30 2700 68 and we'll see exactly why that happens but basically the numbers are going up to the largest value can represent and then when it goes one more becomes a negative number so these are really important understood thanks to understand I mean ninety percent of the time maybe you can just get by writing programs and not worrying about whether your numbers are going to exceed their possible range but they sometimes when this could be really important if you're like you know controlling a rocket you really don't want the positive thrust to