0

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?

3
  • How are you getting these values at first place Commented Jul 24, 2013 at 17:22
  • You could use the PHP's fmod() function Commented Jul 24, 2013 at 17:28
  • 1
    Take the modulus before multiplying. Once you've left the range where integers are exactly represented, you've lost the information. Commented Jul 24, 2013 at 17:30

1 Answer 1

1

You should look into bcmul and bcmod for arbitrary precision computations.

Example:

$res = bcmul('134334244395933282', '2834783723423487283');
$modRes = bcmod($res, '15');
echo $modRes;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.