
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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