Forum und email

bcpowmod

(PHP 5)

bcpowmod — Raise an arbitrary precision number to another, reduced by a specified modulus. 임의 정밀도 수를 계수에 의해 감소하는 다른 수로 제곱한다.

설명

string bcpowmod ( string $x , string $y , string $modulus [, int $scale ] )

x 를 계수 modulus 와 관련된 y 제곱하기 위한 고속-멱법(fast-exponentiation) 기법을 사용한다. 선택적인 scale 매개변수는 소수점 이하 자릿수를 설정하는데 사용된다.

다음 두 구문은 기능상 동일하다. 하지만 bcpowmod() 버전은 좀더 짧은 시간에 수행되고 더 긴 매개변수를 허용한다.

<?php
$a 
bcpowmod($x,$y,$mod);

$b bcmod(bcpow($x,$y),$mod);

/* $a and $b are equal to each other. */
?>

Note: 이 방식은 계수 연산을 사용하기 때문에, 자연수가 아닌 수를 사용하면 기대하지 않은 결과를 낼수 있다. 자연수는 0이 아닌 양의 정수이다.

bcpow(), bcmod() 참고.