Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_random_bits

Description

The gmp_random_bits of GMP for PHP random number.

Syntax

gmp_random_bits(
    int $bits
): GMP

Parameters

bits

The number of bits to generate.

Return

Returns a random GMP number.

Examples

1 · bits

<?

$bits = 3;

$return = gmp_random_bits($bits);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "2"
}

2 · base · 2

<?

$bits = 3;

$return = gmp_random_bits($bits);

var_dump($return);

$base = 2;

$gmp_strval = gmp_strval($return, $base);

echo $gmp_strval;

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "4"
}
100
HomeMenu