In this lecture, we'll look at the data types that we commonly use to represent integers in RC Sharp code. So what is an integer? An integer is a number without a decimal or fractional part like 0 or 42 or negative 11. The four most commonly used integer data types in C sharp are, byte, short, int and long. So what's the difference between them? The difference is the number of bits that we use to represent each of those data types. So a byte is represented in memory with eight bits and a short uses 16 bits and int uses 32 bits and along uses 64 bits. What does that tell us? Well, we know that 2 to the b equal n. So we know that if b is smaller than n is smaller. So a byte can only store 256 unique values from 0 to 255 and then as we move through short, int and long, we get a wider range of values that we can represent in that particular data type. The operations for our integer data types in C Sharp are pretty much what you would expect except for division. So think back to your grammar school or grade school days, when you learned how to do division and when you did division, you came up with a quotient and a remainder. While the division operator on integer data types in C Sharp gives us the quotient and we'll explore that some more once we start coding with integers. So let's start coding with integers. I've started up visual studio and I'm going to create a new project, we're building another console apps. So I'll make sure that selected and click next. I'll call this one integer data types and say next. And remember, we want to make sure that we check this check box, so that we get the full main method rather than the abbreviated code that we get. If we don't check this checkbox and click create and I'm going to comment the program into your data types lecture code and I'll comment the main method as well. Three slashes and I'll say, demonstrates into your data types. And I'll add a comment here that says, these are the command line args or command line arguments. We won't use command line arguments and any of the courses in the specialization, but they can be useful with console apps, especially if you do batch processing of assets for your games. But we won't cover that topic in the courses here. Okay, we don't want to say Hello World. Instead, we're going to declare a variable which will get too soon. And then I'm going to say, calculate minutes and seconds played. So we're going to start with a total seconds played for a game and then we're going to calculate how many whole minutes that is and how many whole seconds that is. And then we'll print those out as well. As I said, I'll start by declaring a variable and we start with the data type and because the total seconds played will be a whole number. I'm going to use int as my data type and now I give my variable a name, a name for that location in memory and I'll call it total seconds played. Now, you'll notice that I started my variable name with a lower case character and then each word in the middle of the variable name starts with a capital letter. This is not required by C Sharp, but it is standard C Sharp programming practice. So the compiler won't complain if you mix the case all over the place like you might for your passwords and so on, but this is the best way to write your C Sharp code. So that others C Sharp programmers can just glance at a name and know that it's a variable. This style of capitalization actually has a name, it's called Camel Case because here's the head of the camel and then there are some humps on the camel. I didn't make that up, but that's what it's called is Camel Case. So this is a valid variable declaration, but I actually want to give my variable and initial value as well. So I'm going to set it to 100. So I have total seconds played is 100. Now, we'll calculate the minutes played and that will be another whole number. So another int and you'll notice that the intelligence is trying to help me to guess at what I wanted to be but it's guessing wrong. So I'm just going to keep typing, minutes played is equal to and again, I don't want it to be zero, I want it to be total seconds played. And this one I'll take, so tab and actually I do want to divide by 60, so I'm going to hit tab again. And that's a good line of coding, that will use that integer division we talked about, to calculate the total seconds played and that gives us the quotient of that division. Now I want to print minutes plate, you might think I should just keep on typing and type everything in and then try it. But that's not a good idea for developing our software, whether it's for games or just software in general, we should add a little bit and test it and add a little bit and test it. So I'm modeling that behavior for you because that's the right way to do it. We know how to print stuff out, in console apps we use Console.Writeline, I'll tab to accept the right line. And here in the code I'm demonstrating to you. I'm going to label my output so that the user knows what we're printing out. In the programming assignments you do in the courses in the specialization, you won't be labeling output because many people would come up with a variety of different labels for their output. And really as I compare your actual results to the expected results for each assignment, I just want to make sure you've got the numbers right. It would be really hard to make sure everyone got reasonable labels but they're not all the same. So even though we're labeling our output here in the lectures, you won't be labeling the output in the auto graded programming assignments you do in the courses. Okay, I have a label but I don't actually have minutes played. So I'll say plus minutes played. And of course I want to semicolon at the end of that line. So here's how this code works. We know about Console.WriteLine. We've actually printed out string liberals before, this will get printed out literally the way you have it because it's between double quotes. Because this is a string minutes played which we know is an integer will actually get converted to a string. So now we want to join these two strings together and we do that with plus. And this isn't actually mathematical edition, this is called concatenation when we join two strings together. So I'll run the code with ctrl F5 and as you can see minutes played is one which is exactly what we expected. Now, I want to calculate seconds played, another integer. Look, it's trying to help me, so I'll take some of this except I know it's not an integer division. I know I need to do something to get the remainder not the quotient. I also know though, when I do that something and I'll tell you that something now that's the percent sign. So that gives us the remainder in integer math, but I don't want to type 60 again. This is the second time I'm typing 60 and 60 isn't just some generic number. It actually has semantic meaning, this 60 here means how many seconds per minute. This is actually called a magic number because somebody who's reading your code later has to magically know that 60 means seconds per minute. So let's actually declare a constant that will actually make it much clearer in the code what that 60 means. When we're declaring a constant, we say const and then we provide the data type int, and now I want seconds per minute. And I'll set it equal to 60. Now you'll notice for constance I start the constant name with a capital letter and I do the same thing with each word in the constant name, but it starts with a capital letter, not a lower case letter. Again, that's not required by the C Sharp language, but it is good C Sharp programming practice. And this capitalization scheme also has a name and it's called Pascal Case because that's how we used to name things in the ancient, but great teaching language pascal. So now if we come down here and replace those 60's with seconds per minute, it makes our code much more readable for us to understand. Now, this is pretty straightforward, right? Somebody could probably figure out that because of the math we're doing, the 60 means seconds per minute. But as you build more interesting games or more interesting code, you might have the number ten for what damage a particular weapon does. And you might also have a ten for how many seconds the cool down is for after you fired your weapon. And somebody would have to magically know which tens meant weapon damage and which tens meant cool down time. So using constants really helps to get rid of those magic numbers and make our code more readable, okay? And so, now we'll print out the second plate as well. And I'll print out the value of the variable that we just calculated. And when I ctrl F5, you can see we played 1 minute and 40 seconds, if we played for 100 seconds. And you should be able to convince yourself that that is the correct math for playing 100 seconds. Last comment before we leave visual studio, I will say that if you go to the internet and look up how to declare a variable, you'll find lots of people saying, you don't have to put int. You can just put var and that's true. That's valid C Sharp, I'm not trying to be offensive, but let me tell you, if you're using var as you're trying to learn how to program. It's because you're too lazy to try to figure out the actual data type you want to use. And at least in an introductory set of courses, I want you to actually think about what data type each variable should be. You can certainly get away with saying var in C Sharp, but I'd really prefer you to explicitly figure out the data types you need when you're declaring your variables. Okay, let's see how well you can do int to your math. So look at this slide and pause the video and come up with your answer and then unpause the video. Well, the answer is 1 plus 1 is 2, isn't this awesome? You're taking a college level class and you're able to do 1 plus 1 and hopefully you got 2 and so, this is great, you can do college math. This next one is a little more challenging. So go ahead and look at this question, pause the video, come up with your answer and then unpause the video when you're ready. The answer to this one is probably counterintuitive to you because the number we start with is the maximum possible integer, we can represent with 32 bits. So when we add 1 to it we get the minimum or smallest negative number we can represent with 32 bits. I've provided an additional reading for you in the lecture resources, so you can understand if you want why this actually happens. But we wrap around from the biggest possible number to the smallest negative number and just in case you think, well that's great. You're a geeky professor and that's of academic interest, but who cares? Well, it turns out that rock star cares because in the initial release of Grand Theft Auto 5, they ran to this exact problem. So a player got very, very, very rich and then they earned a little more money and they were, very, very bankrupt. And it was because 2 to the b equal n and that integer number wrapped around. And so, this is not just of academic interest, it actually really matters for game development. Before we end this lecture, I want to talk a little bit about the difference between value types and reference types. So value types, the bits that are stored in the memory location are interpreted as a particular value, for this particular lecture, those bits are interpreted as some whole number. It might be a byte, short, int or long, but a whole number. When we get to the next module, when we talk about classes and objects, we'll talk about something called reference types. Where the bits in the memory location for a particular variable are actually interpreted as a reference to an object somewhere else in memory. We don't really need to worry about that until we get to classes and objects, but because this was my first opportunity to talk about value types versus reference types. I wanted to take advantage of that here. Okay, so to recap, we learned about the commonly used data types that we can use to represent whole numbers in our C Sharp code. And I will say that we will pretty typically just use int as our whole number data type, although there are other times that we might opt to use those other data types, in general will use int for our game development. And we also learned that one of the limitations of 2 to the b equal n is that, integers will wrap around from either the lowest negative to the highest positive or the highest positive to the lowest negative. If we reach the biggest number we can represent with a particular sign.