Reputation: 81
why this function return 0 ?
public function encrypt(){
return (pow(123,17)%3233);
}
Upvotes: 2
Views: 132
Reputation: 59691
What happens here is you get an integer overflow. Your number is way bigger than PHP_INT_MAX
. So to still be able to do this calculation you can use the BC math library .
So just use bcpowmod()
, e.g.
echo bcpowmod(123, 17, 3233);
Upvotes: 2