PHP fdiv() Function
Last Updated :
27 Mar, 2023
The fdiv() is an inbuilt PHP function that returns the result of a division of 2 numbers(in accordance with IEEE 754). The NaN will never == or === for any value while doing the comparison, even including itself.
Syntax:
fdiv(float $num1, float $num2): float
Parameters: This function accepts 2 parameters:
- num1: This parameter indicates the dividend or numerator.
- num2: This parameter indicates the divisor number
Return Value: This function returns floating point values by dividing num1 / num2. The INF, -INF, or NAN will be returned if the second number is zero.
Example 1:The following example demonstrates the fdiv() function.
PHP
<?php
var_dump(fdiv(5.7,1.3));
var_dump(fdiv(3,2)) ;
?>
|
Output:
float(4.384615384615385)
float(1.5)
Example 2: The following example demonstrates the fdiv() function.
PHP
<?php
var_dump(fdiv(10,2));
var_dump(fdiv(4,2)) ;
?>
|
Output:
float(5)
float(2)
Reference: https://www.php.net/manual/en/function.fdiv.php
Share your thoughts in the comments
Please Login to comment...