In this lecture, we'll talk about the data types we use in C# to represent real numbers. So real numbers are those numbers that have a decimal point. And we actually have a problem as we try to represent real numbers in a computer because real numbers are in what's called the continuous domain. There are an infinite number of real numbers between zero and one, for example, and we know though that two to the b equal n. And so given a limited number of bits, we can only represent a finite number for n, so it's actually impossible for us to represent the whole range of infinite real numbers in a computer. So we actually have to do our representation in something called the discrete domain, not the continuous domain, and this discrete domain is what we use zeros and ones to represent things in. So we can represent lots of real numbers but we can't represent all real numbers. And what that leads to is some inaccuracy in the numbers that we can represent. Some of those infinite real numbers get represented with the same sequence of bits in the computer because two to the b equal n. Okay, so the data types that we commonly use and C# to represent these real numbers we use something called floating numbers and that's just the way we represent real numbers in a computer. And the two data types we'll commonly use our float and double. And in fact, in game development in our unity game development, we're regularly going to just use float just as we regularly use int even though we have a number of different integer data types we can use, we'll find ourselves using float most of the time. The difference between float and double is the number of bits used to represent those data types. We get twice as many bits for doubles as we do for float. And what does that tell us? We know that doubles can represent more things than float because they have twice as many bit. The operations for both floats and doubles are as we'd expect and so we can just go and do an example program using float. I created the new console app project in MonoDevelop and added documentation comments for the class and for the main method. I have also added a couple of variables. So these variables are the score that I achieved while I was playing the game and the total seconds played, 10,000 seconds, which is not bad at all. And what I want to do for this problem is I want to calculate and print points per second, and some of you may be furious you might be saying, "Well, a real gamer would calculate DPS or Damage Per Second," but that's okay. The concepts are the same. So let's say this was an action game and so we want to know our points per second. So to declare a float variable is very similar to declaring an int variable. We put the data type float and I will call those pointsPerSecond and I will deliberately make a mistake and then we will discuss how to fix that mistake. So you could certainly assume that an appropriate way to calculate pointsPerSecond is to divide score by totalSecondsPlayed and then we'll print it out, of course, with the label. And our control F5. And you'll see that it says points per second is zero. Now, if we think about this we'll understand that even though my pointPerSecond variable is declared to be a float, I have score as an integer and total seconds played as an integer. And so this division right there is going to do integer division. I could, in fact, change one of these to a float, but that is sort of an ugly solution to this problem because they're not float right? They're whole numbers. And so we should store them as whole numbers, as ints. The solution to this problem is to- for this calculation, make at least one of them be treated as a float. So I can do that using something called a typecast. So the way I do a typecast is I do open parentheses the type I want to cast this variable two and close parentheses. So what this typecasts does is it says just for this calculation temporarily treat score as a float. It doesn't change the underlying data type of score. score is still in int as declared. But for this calculation it treats score as a float. Once it treats the numerator as a float it will actually automatically convert the denominator to a float when it does the division. So in fact, it will be doing floating point division instead of integer division. So with the typecast you can see that my points per second are actually 0.136, which if you do this division all by yourself you'll see that is the correct answer. So I sometimes will find myself needing to do these typecasts to temporarily convert an int variable to a float for a calculation. I will point out that you should not do this. You should not try to typecast the whole thing here because if you do, let's see what happens. I get zero again, and I get zero again because it does the integer division coming up with a zero and then it says, "Oh you want that zero to be a float? Okay. It's a float." So although there will be times when we want to typecast sort of bigger calculations, your first instinct should be to typecast a particular variable to force the math to work out the way you want it to work out. And that's really it for the code for today. We've declared a floating point variable and we've learned about typecasting as a mechanism for making- particularly division, that's one of the places where we need to be concerned about this, to make a division do floating point division rather than integer division. Before we finish this lecture, you should go do an in-video quiz showing that you understand this idea of what happens when we represent real numbers from the continuous domain in a computer. And there you have it. We've used floating point numbers, specifically float, in an example program today to see how that works in C#.