How does PHP calculate integer division?

autoload
Release: 2023-03-08 18:36:02
Original
2864 people have browsed it

1. Grammar

    intdiv(divident, divisor);
Copy after login

2. Example

<?php   
     $a = 10;
     $b = 3;
    
    
    $c = $a/$b;//正常除法   
    print("$a/$b="."$c \n");//10/3=3.3333333333333
    echo "<br>";
    var_dump($c);           //float(3.3333333333333) 

?>
Copy after login
<?php   
     $a = 10;
     $b = 3;
    
  
    $c = intdiv($a, $b);  //使用intdiv()函数
    print("$a/$b="."$c \n");//10/3=3
    echo "<br>";
    var_dump($c);           //   int(3) 
?>
Copy after login

In fact, the function of this function is to round down, without rounding of.

Recommended: php video tutorial php tutorial

The above is the detailed content of How does PHP calculate integer division?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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!