Floor Function in PHP

Floor Function in PHP. A Php program to print the number using the floor method. By using this method we can execute the program with floor function. Another built-in function in PHP interpreter is the floor() function. Any float number can be passed as an argument, and it will be rounded down to the next lowest integer. Because the range of float is larger than that of integer, this function always returns a float number.

<?php 
echo (floor(5.7)."<br/>");
echo (floor(3.333)."<br/>");
echo (floor(-1.8)."<br/>");
?>

 

Output:

5

3

-2

Float Datatype in Php

A float is a data type in computer science that is formed of a number that is not an integer since it includes a fraction written in decimal notation. Some argue that the float data type is employed in computer programming when more accuracy than integers can give is required. 

A floating-point or float variable is a type of variable in programming that is used to hold floating-point numeric values. A floating-point number is one in which the decimal point can “float” rather than being fixed within a number. 4.5 is an example of a floating-point number.

Floor Function in Php

Another built-in function in PHP interpreter is the floor() function. This method takes any float value as an input and rounds it to the nearest integer. Because the range of float is greater than that of integer, this function always returns a float value.