fdiv() function in PHP 8

WBOY
Release: 2023-09-09 13:52:02
forward
1279 people have browsed it

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
Copy after login

Example 1: Using PHP8’s fdiv() function

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

Output

3.75
Copy after login

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)
?>
Copy after login

Output

INF-INF NAN
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!