In this lecture, we're going to explore a little more deeply how to read documentation. And I know no one ever says I want to develop games so I can read the documentation, but this is really a critical skill for programmers. Throughout your programming life, you'll spend time reading C plus plus documentation or unreal engine documentation. Maybe not even through your programming life, through the courses in these specializations, but you have to be able to do it for code that other people have provided to you. Watching me do it is not going to help you learn how to do it, you're just going to have to practice and practice and practice, but you're going to have to do it to be able to become a good programmer in any particular domain. Let's go solve a small problem that requires us to get some practice reading documentation. Here's our template console app with the copyright notice added, and the comment added above our main function and the comment that says what we're going to do in this particular chunk of code. And what we're going to do is we're going to calculate and print the cosine of 45 degrees. So we'll start by declaring a variable that holds the angle. And I have a choice of data type here, right? I can do int if I want to do whole numbers for degrees, I can do float if I want to do floating point numbers for degrees. So I think I'll make this a float and I'll call it angle and I'll initialize it to 45. So now I have an angle in 45 degrees, and I need to figure out how to calculate and print the cosine. Of course, the first step and that is to calculate the cosine, and this is where reading documentation helps us. So if you're using visual studio and you have installed local help, then you can just say help, view help. And it's reasonable to guess that cosine, the standard abbreviation for cosine will be something we can use. So if we search on cosine well, just click that first hit and we discovered that there are a number of versions of cosine. So here are those three versions of getting a cosine that we could use. We have a cosine function that takes a double as an argument, it's a parameter on this side, but it's an argument when we call it and it returns a double. We have a cosine F that takes a float and returns a float, and then we have co sign L which takes a long double and returns a long double. In all of these for the argument, we could pass in an int, for example, and it would get promoted to the appropriate parameter type when we call the function. So we don't have to worry that we can only explicitly pass a double to cosine here, for example, we could pass a float, we could pass an int, we could pass any of the smaller data types, and they get promoted to a double. Let's use this one, because we're going to try to use float pretty consistently throughout our unreal engine games, so we'll try to use floats here in our console apps as well. So you've sort of read the documentation as fast as you can because you didn't go into game development to read documentation. So you read this parameter X, and you say it's the angle and you say great, I know it to pass and you stop reading right there and you leap back into your code. If you don't have visual studio, local help installed or you're working in X code, the C plus plus reference web page is a good place to go to find out information about C plus plus code. Think of this as the C plus plus documentation that's authoritative and reasonable and so on. So if we go up here in the upper right hand corner into that same search on coast and hit enter, we find this, which also gives us similar documentation, right? We have this one, we have the double one, we have the long double one, and there are some other versions listed as well. But essentially we're looking at approximately anyway, the same documentation. And again you'd say, okay, the parameter arg is a value representing an angle and you're excited to get back to work, so you get back to work. I'm going to put the cosine into a variable before I print it out, that's of course not required, we could just print it out directly, but we're still practicing, declaring variables and assigning values to them and so on. So let's do that here as well. So I'll call this one cosine and I'll say equal to cos f of my angle. And I'll print it out. With the label because we're not submitting this to an automated greater. So when we run it, it says that's the cosine of 45 degrees and we're all excited, we say, hey, that's great, we got a number, it must be right. It's not right, it's not the correct cosine of 45 degrees. And that reminds us again that when we run our code to test it, we have to know what the right answer is to be able to tell if we're getting the right answer and we're not. So now our issue is what's going wrong? And your first instinct, as you look at this code is fairly straightforward, it seems like it should work. You say I must be doing something wrong, I better go back and look at the documentation again. When you do, you read this entire sentence and it says angle in radiance or you look at this documentation and you see it's as angle in radiance. So now we come back here and we realize that the problem is our angle is in degrees and we're calling the cos f of function as though the angle was in radiant. So let's convert, Angle to radiant. So we can take angle on the left hand side of this assignment statement, we're giving angle a new value, and we can say angle times something. So you have to know how to convert degrees to radiant, and it turns out that 360 degrees is equivalent to 2 pie radiance, so 180 degrees is equivalent to pie radiance. So if we take degrees and we multiply by pie over 180, we will have converted to radiance instead of degrees. I'll start by doing it the way you shouldn't do it, 3.1415 float divided by 180. And I'll explain why we shouldn't do it that way in just a moment, but I'll run the code and we get 0.707 and change, and it is the cosine of 45 degrees at least to three decimal places. But we shouldn't do this piece, we should try to find out if there's a constant that's available to us that represents pie, because you have to imagine that people using C plus plus for computation must use pie more than once. So somebody somewhere should have declared a constant for it. Let's go see if we can find it in the Microsoft help viewer. We can just search for pie, and that doesn't help us much. Let's go to the C plus plus reference and search for pie, and none of those things are helpful. And at this point, you might say, well, I'm not getting anything that helps me, I should do something else. And there's something else that you can do that people regularly do is to go Google or Bing or Yahoo or whatever your favorite search engine is. You might go looking for pie in C plus plus, so let's do that. I'll go to Google, And I'll say pie in C plus plus, and see what I can find out. And you have to search around a little bit, sometimes you can find it down here, and this will actually be helpful to us right here, so let's follow this link. And we can scroll around a little bit, and we can see that sometimes some compilers, including all the compilers we're going to be used, declare a constant called M underscore pie. So we can use M underscore pie with a little extra work in our code. I will say that searching the internet for help in discovering things like this is a really good technique to use. You have to have your Internet filter so that you recognize what seems to make sense and what doesn't make any sense at all, but this in fact make sense. So we'll go back to our code and we'll put M pie here just like it was talking about, but we get red squiggles, and that's disconcerting to us. Unfortunately, one of the side effects of using C plus plus across multiple different platforms is different platforms deal with the C plus plus libraries in different ways, and in visual studio, not an X code. But in visual studio, we need to include a pan define use that defines in our code. And we can compile again at this point, and we can run again at this point, and we see that that number is slightly different from what we had before. It's more correct than the number we got previously when we just used 3.1415 because the M pie constant is to more decimal points of precision for a pie than just four decimal points of precision. So we did a couple of things here, we read the C plus plus documentation directly finding the cosine function and particularly the cosine f function that we used here to calculate our cosine. We learned the importance of carefully reading the documentation, especially for the arguments that we provide to functions when we call them. And finally we learned that sometimes just guessing what we're going to need and going into the documentation doesn't help us, so we have to google some reasonable search terms and then filter through the results, trying to find what we need. And while that might feel frustrating, it is also a natural part of programming, so reading documentation and searching for answers that aren't immediately obvious in the documentation are both important skills for you to develop. In this lecture, you got some more practice reading documentation.