Home  >  Article  >  Backend Development  >  fdiv() function in PHP 8

fdiv() function in PHP 8

WBOY
WBOYforward
2023-09-09 13:49:021248browse

PHP 8中的fdiv()函数

In PHP 8, the fdiv() function is used to perform IEEE 754 standard floating point division. fdiv() is a mathematical operation that divides two numbers and returns a floating point number.

fdiv() The function works similarly to the intdiv() and fmod() functions, allowing addition to zero. When a number is divided by zero.

  • INF (Infinity or Real Number) – It is the result of a numerical calculation of mathematical infinity.

  • -INF (Negative Infinity) – Negative infinity or a number below -1.796E308.

  • NAN (not a number) – The result of an unspecified numeric calculation, including numeric functions with arguments outside their domain.

Example

0/0 = NAN
INF/INF = NAN

Example 1: Using PHP8’s fdiv() function

<?php
   echo fdiv(15, 4);
?>

Output

3.75

Example 2: Using the 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

The above is the detailed content of fdiv() function in PHP 8. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete