note 67188 deleted from language.operators.arithmetic by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:04:37 +0000 |
| Subject: | note 67188 deleted from language.operators.arithmetic by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189803@lists.php.net to get a copy of this message | ||
Note Submitter: andr3a at 3site dot it
----
[ops ... wrong example :D]
just a note about module, it works only with integers.
<?php
$a = pow(2, 31);
$b = ($a / 2) - 1;
echo implode('<br />', array(
$a + $b, // OK => 3221225472
$a - $b, // OK => 1073741825
$a * $b, // OK => 2.3058430070662E+018
$a / $b, // OK => 2.0000000018626
$a % $b // WTF ? => -2
));
?>
maybe bc_mod with a string cast should be a solution
bc_mod((string)pow(2,31), (pow(2,31)/2)-1)