[MUSIC] The next data type we're going to talk about are the floating point numbers. As you can see, with the little sea turtle, he's really happy when he's floating in the sea. So here are the float types in C, float, double, and long double. And these are three types that are, Usually ordered in shortest to longest. And we'll see there is a catch here, that's not guaranteed. So the shortest is float, and its range is typically from 10 to the -38, so a pretty small number, to 10 to the positive 38, pretty large number. For example, scientists think that the universe is something like 10 to the 88th atoms. So that's an even larger number, but this is still pretty significant. For example, on Earth, there's something like 7 times 10 to the 9th people, or 7 billion people. And then that can be expressed with six significant figures, as in 0.123456, and then there's an exponent part, which is 10 to the 12th. And showing the exponent part of the float, we use an e. So this is a general way to write the integer part, the fractional part, the exponent, and then a plus or minus integer here. You can consider that there's a sign, a sign of the entire floating point number, a fraction, and the exponent. Now, if we go to, on most machines, the longer type, and typically, again, if you use the sizeof operator on a float, you'd find mostly that it was four bytes. And double you'd find is twice as large, or 8 bytes, and that lets us express more stuff. So one of the things that gets increased is the range. The range becomes from this extremely small number, 10 to the -308, up to a very large number, 10 to the 308. Then we would have no problem representing the number of atoms in the universe. And instead of 6 or 7 significant figures, we typically get 15 significant figures. Finally, We have long double. And long double, when it's implemented and is larger than double, Stays with the same exponent range, but it adds a great deal more significant figures. So there's an IBM implementation where there are 31 significant digits, but again, this can be system dependent. So we have in the C system these three types, float, double, long double. You can declare a variable of any one of these types. The notion is float conserves the most space. Double is typical, so frequently I just use double for most of my things. And long double gets you all this extra significant figure. But the only thing guaranteed by the C compiler is if there's a double, it will be at least as large as float and at least as significant. And if there's a long double, it will be at least as large as double and as significant. So it could conceivably, on some especially early C system, all three of these could really mean the same thing. But then on some modern supercomputer, they may also be clearly distinguished in the way we just talked about. Finally, we have to know how to write literals or constants. And here's three ways to write the constant 1. Notice 1 is not of that way, so it's not possible. If you write down 1 without a decimal point, that's going to be the integer literal. And we're going to see later when mixing types, this can be very important. So if we want, we can write 1.0, which is quite clear, or 1., and not have the fractional part. Or we could write 0.1 e of 1, which is another way of saying that's a power of 10. So that would just shift it to 1, and this would be the least confusing. But all of these would lead to the same literal, that's a float. Now, It's important to understand that significance [COUGH] is critical, In a computation. So when you're dealing with these numbers, they are not like real numbers from mathematics. In the world of mathematics, there ostensibly is a place on the real line where you could show pi in all its glory, 3.14159, etc., etc., etc. With as much precision as you want. In a standard representation, like a double, for pi, you could only get your 6 or 15 significant digits represented as a double, so you're going to lose some precision. And think about where this could show up. You might have a computation which looks okay, like you've added a tenth, the real number, a tenth, to the real number 123. By real number, I mean double, 123 raised to the 10th or the 12th power. It turns out this number is so large that when that's added in, the result is no change on this number. It's dwarfed by the larger part of the number. So that means this computation, if you put it in some expression, Would not have an effect. And in more advanced courses on numerical analysis, people who are specialists in this have to keep track of loss of precision and some of the precision that may come about. Because a number that looks like it's precise in decimal might not translate to it being precise under the kind of binary representation that's used for a floating point number. So something like 1 and one-third, 1.33333, might not have the same kind of precision when it's translated to the internal number. Okay, finally, we also want to know how to do input and output with these floats. So that means we want to know about conversion characters, and we have a selection of conversion characters available. We can use %e or %E, and then it prints as a number with a fraction and an exponent part. Or we can have a %f, and it prints as a number written out but without the exponent. Finally, we can have a more flexible format, which is %g or %G, and they pick from e or f and decide on which one to use based on what gives you the shortest representation. So this is more flexible, but you might end up with one or the other, depending on which is shortest on printing to the screen. [MUSIC] Okay, in the next segment, I'm going to use some of those ideas and actually write a little piece of code to show some of those ideas. And get you used to printing, [MUSIC] Doubles and also to using the math library, which has functions like square root and signs. So you might look online to do a little work on how the math library can be used. [MUSIC]