|
Free
PHP Tutorials
|
![]() |
home |
Stay
at Home and Learn
|
|||||
PHP Tutorials |
||||||
|
Floating Point Numbers in PHP
A floating point number is one that has a dot in it, like 0.5 and 10.8. You don't need any special syntax to set these types of numbers up. Here's an example for you to try: <?php $first_number = 1.2; print ($sum_total); ?> You add up, subtract, divide and multiply these numbers in exactly the same way as the integers you've been using. A warning comes with floating point numbers, though: you shouldn't trust them, if you're after a really, really precise answer!
Some ExercisesTo round up this section on number variables, here's a few exercises (In your print statements, there should be no numbers just variable names): Exercise Exercise Exercise (200 * 15) / 10 Use a print statement to output your answer.
In the next part of these PHP tutorials, we'll take a look at Conditional Logic.
|