GMP gmp_random_bits
(PHP 5 >= 5.6.3, PHP 7, PHP 8)
gmp_random_bits — Random number
설명
gmp_random_bits(int $bits
): GMP
난수를 생성합니다. 숫자는 0과 (2 ** bits
) - 1 사이입니다.
bits
는 0보다 커야 하며 최대값은 사용 가능한 메모리에 의해 제한됩니다.
매개변수
bits
- 비트 수입니다.
반환 값
임의의 GMP 번호입니다.
Examples
예제 #1 gmp_random_bits() 예제
<?php
$rand1 = gmp_random_bits(3); // random number from 0 to 7
$rand2 = gmp_random_bits(5); // random number from 0 to 31
echo gmp_strval($rand1) . "\n";
echo gmp_strval($rand2) . "\n";
?>
위의 예는 다음을 출력합니다.
3 15