I get integer overflow value 7.233907357909E+16 from multiplication.
Now i need to calculate modulus 7.233907357909E+16 % 15.
How can i solve it, any idea how to do this?
asked Jul 24, 2013 at 17:19
Idham Perdameian
2,27725 silver badges34 bronze badges
-
How are you getting these values at first placeuser2541120– user25411202013年07月24日 17:22:58 +00:00Commented Jul 24, 2013 at 17:22
-
You could use the PHP's fmod() functionMark Baker– Mark Baker2013年07月24日 17:28:27 +00:00Commented Jul 24, 2013 at 17:28
-
1Take the modulus before multiplying. Once you've left the range where integers are exactly represented, you've lost the information.Daniel Fischer– Daniel Fischer2013年07月24日 17:30:35 +00:00Commented Jul 24, 2013 at 17:30
1 Answer 1
You should look into bcmul and bcmod for arbitrary precision computations.
$res = bcmul('134334244395933282', '2834783723423487283');
$modRes = bcmod($res, '15');
echo $modRes;
answered Jul 24, 2013 at 17:23
jh314
27.9k16 gold badges66 silver badges83 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-php