PHP - calculating a large integer module

I need to calculate a module with a large number, for example:

<?php

    $largenum = 95635000009453274121700;

    echo $largenum % 97;

?>

It does not work ... because $ largenum is too big for an int in PHP.

Any idea how to do this?

+3
source share
1 answer

Use from BCMath 's mathematical precision accuracy : bcmod()

$largenum = '95635000009453274121700';
echo bcmod($largenum, '97');

Note that it $largenumis passed as a string not converted to int.

+17
source

Source: https://habr.com/ru/post/1706581/


All Articles