Working with large numbers in PHP

前端 未结 8 997
一个人的身影
一个人的身影 2020-11-22 11:22

To use modular exponentiation as you would require when using the Fermat Primality Test with large numbers (100,000+), it calls for some very large calculations.

Whe

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 12:03

    $x = 62574 * 62574;
    
    // Cast to an integer
    $asInt = intval($x);
    var_dump($asInt);
    var_dump($asInt % 104659);
    
    // Use use sprintf to convert to integer (%d), which will casts to string
    $asIntStr = sprintf('%d', $x);
    var_dump($asIntStr);
    var_dump($asIntStr % 104659);
    

提交回复
热议问题