note 117626 added to function.intdiv
| From: | AmeenRoss | Date: | Sat, 11 Jul 2015 13:15:53 +0000 |
| Subject: | note 117626 added to function.intdiv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203076@lists.php.net to get a copy of this message | ||
This does indeed seem to be equal to intdiv:
<?php
function intdiv_1($a, $b){
return ($a - $a % $b) / $b;
}
?>
However, this isn't:
<?php
function intdiv_2($a, $b){
return floor($a / $b);
}
?>
Consider an example where either of the parameters is negative:
<?php
$param1 = -10;
$param2 = 3;
print_r([
'modulus' => intdiv_1($param1, $param2),
'floor' => intdiv_2($param1, $param2),
]);
/**
* Array
* (
* [modulus] => -3
* [floor] => -4
* )
*/
?>
----
Server IP: 72.52.91.14
Probable Submitter: 87.212.81.141
----
Manual Page -- http://php.net/manual/en/function.intdiv.php
Edit -- https://master.php.net/note/edit/117626
Del: integrated -- https://master.php.net/note/delete/117626/integrated
Del: useless -- https://master.php.net/note/delete/117626/useless
Del: bad code -- https://master.php.net/note/delete/117626/bad+code
Del: spam -- https://master.php.net/note/delete/117626/spam
Del: non-english -- https://master.php.net/note/delete/117626/non-english
Del: in docs -- https://master.php.net/note/delete/117626/in+docs
Del: other reasons-- https://master.php.net/note/delete/117626
Reject -- https://master.php.net/note/reject/117626
Search -- https://master.php.net/manage/user-notes.php