
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
fdiv() function in PHP 8
In PHP 8, fdiv() function is used to perform floating-point division on IEEE 754 standard. fdiv() is a mathematical operation that divides two numbers and returns a floating-point number.
The fdiv() function works similar to the intdiv() and fmod() function, which allows division by zero. Instead of showing an error, the fdiv() function returns INF, -INF or NAN, when a number is divided by zero.
INF (Infinity or real number) – It is the result of a numerical calculation that is mathematically infinite.
-INF (Negative Infinite) – it is a negative infinite number or a number below -1.796E308.
NAN (Not a Number) – it is the result of an unspecified numerical calculation, including the numerical functions whose parameter is outside their field.
Example
0/0 = NAN INF/INF = NAN
Example1: using fdiv() function PHP8
<?php echo fdiv(15, 4); ?>
Output
3.75
Example2: using fdiv() function
<?php echo fdiv(10, 0); // INF (Infinite) echo fdiv(-10, 0); // -INF (Negative Infinite) echo fdiv(0, 0); // NAN (Not a number) ?>
Output
INF-INF NAN
- Related Articles
- str_starts_with and str_ends_with function in PHP 8
- How to get resource ID using get_resource_id() function in PHP and PHP 8?
- Attributes in PHP 8
- Number comparisons in PHP 8
- Named Arguments in PHP 8
- Union Type in PHP 8
- Match Expression in PHP 8
- Nullsafe Operator in PHP 8
- strcmp() function in PHP
- strcoll() function in PHP
- strcspn() function in PHP
- strip_tags() function in PHP
- stripcslashes() function in PHP
- stripos() function in PHP()
- stristr() function in PHP
