Home >Backend Development >PHP Problem >How does PHP calculate integer division?

How does PHP calculate integer division?

autoload
autoloadOriginal
2021-03-16 17:38:052993browse

1. Grammar

    intdiv(divident, divisor);

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) 

?>
<?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) 
?>

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!

Statement:
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

Related articles

See more