(PHP 8 >= 8.2.0)

Random\Engine\PcgOneseq128XslRr64::jumpEfficiently move the engine ahead multiple steps


public Random\Engine\PcgOneseq128XslRr64::jump(int $advance): void

Moves the algorithm’s state ahead by the number of steps given by advance, as if Random\Engine\PcgOneseq128XslRr64::generate() was called that many times.

Liste de paramètres


The number of steps to move ahead; must be 0 or greater.

Valeurs de retour

Aucune valeur n'est retournée.

Erreurs / Exceptions

  • If advance is less than 0, a ValueError will be thrown.


Exemple #1 Random\Engine\PcgOneseq128XslRr64::jump() example

= new \Random\Engine\PcgOneseq128XslRr64(0);
$b = clone $a;

for (
$i = 0; $i < 1_000; $i++) {

"A: ", bin2hex($a->generate()), "\n";
"B: ", bin2hex($b->generate()), "\n";

L'exemple ci-dessus va afficher :

A: e6d0d5813913a424
B: e6d0d5813913a424

Exemple #2 Randomizer methods may call the engine more than once

= new \Random\Randomizer(new \Random\Engine\PcgOneseq128XslRr64(42659));
$b = new \Random\Randomizer(clone $a->engine);

$a->getInt(1, 1572864); // Performs two calls to generate().
$a->getInt(1, 1572864);


// Because the first call to ->getInt() called ->generate() twice
// the engines do not match up after performing a ->jump(2).
echo "A: ", bin2hex($a->engine->generate()), "\n";
"B: ", bin2hex($b->engine->generate()), "\n";

// Now the B engine matches the A engine.
echo "B: ", bin2hex($b->engine->generate()), "\n";

L'exemple ci-dessus va afficher :

A: 1e9f3107d56653d0
B: a156c0086dd79d44
B: 1e9f3107d56653d0
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top