1 00:00:00,310 --> 00:00:02,740 Not all numbers are as simple as integers. 2 00:00:02,740 --> 00:00:07,854 We often need to keep track of fractional values like products that cost \$1.99, 3 00:00:07,854 --> 00:00:10,640 or distance like 2.5 miles. 4 00:00:10,640 --> 00:00:12,850 Those values are called floats. 5 00:00:12,850 --> 00:00:18,170 Floating point integers, real numbers or doubles, all names for the same thing. 6 00:00:18,170 --> 00:00:21,430 For decimal numbers we use the PHP variable type float. 7 00:00:23,250 --> 00:00:25,720 Let's start by commenting out these var dumps. 8 00:00:28,840 --> 00:00:32,050 Now let's say we want to find the distance of a trip. 9 00:00:32,050 --> 00:00:36,532 So we'll create two variables here, distance home and distance to work. 10 00:00:36,532 --> 00:00:41,800 Distance_home, we'll set this equal to a floating point and number. 11 00:00:43,040 --> 00:00:46,040 We simply set this variable equal to 1.2. 12 00:00:46,040 --> 00:00:50,250 Enclose the statement with a semi colon. 13 00:00:50,250 --> 00:00:54,550 Then we'll add our second floating point variable distance to work. 14 00:00:54,550 --> 00:00:58,630 And will set this equal to 2.5. 15 00:00:58,630 --> 00:01:01,930 Again ending with a semi-colon. 16 00:01:01,930 --> 00:01:06,020 Now we can use the same type of operations we've done before. 17 00:01:06,020 --> 00:01:10,692 Let's do a var dump, and we'll dump 18 00:01:10,692 --> 00:01:16,431 the distance home plus the distance to work. 19 00:01:18,715 --> 00:01:21,030 All right, now let's save and 20 00:01:21,030 --> 00:01:25,928 run our script AS you can see we can take floating point numbers and 21 00:01:25,928 --> 00:01:31,230 add them together and get returned a floating point value. 22 00:01:31,230 --> 00:01:34,720 Now what if I were to add a non floating point number to this equation. 23 00:01:35,810 --> 00:01:42,680 So let's say we'll and the variable num 3. 24 00:01:42,680 --> 00:01:44,560 Number three is a whole number. 25 00:01:44,560 --> 00:01:46,890 So let's save this script and run it again. 26 00:01:49,780 --> 00:01:50,760 Now we see 6.7. 27 00:01:50,760 --> 00:01:55,430 So if we take whole numbers and we sum them to floating point numbers 28 00:01:55,430 --> 00:01:57,970 we're still going to get a floating point in return. 29 00:01:59,110 --> 00:02:02,638 Let's add one more floating point number to make our results a whole number. 30 00:02:02,638 --> 00:02:08,150 Let's add 0.3. 31 00:02:08,150 --> 00:02:10,800 Again, run the script and 32 00:02:10,800 --> 00:02:14,980 we see the results of seven, but the type is still a float. 33 00:02:16,510 --> 00:02:21,740 Any time we're using a floating point value the result will be a float as well. 34 00:02:21,740 --> 00:02:22,510 Most of the time, 35 00:02:22,510 --> 00:02:26,790 you won't need to worry about defining a variable as an integer or a float. 36 00:02:26,790 --> 00:02:30,120 PHP automatically handles the differences, so you don't have to.