[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomizer::getInt(0, 2**32 - 1) with Mt19937 always returns 1 #9415

Closed
TimWolla opened this issue Aug 24, 2022 · 0 comments · Fixed by #9416
Closed

Randomizer::getInt(0, 2**32 - 1) with Mt19937 always returns 1 #9415

TimWolla opened this issue Aug 24, 2022 · 0 comments · Fixed by #9416

Comments

@TimWolla
Copy link
Member

Description

The following code:

<?php

$r = new Random\Randomizer(new Random\Engine\Mt19937());
var_dump($r->getInt(0, 2**32 - 1));

Resulted in this output:

int(1)

But I expected this output instead:

Not always 1.

PHP Version

Current git master

Operating System

No response

@TimWolla TimWolla self-assigned this Aug 24, 2022
TimWolla added a commit to TimWolla/php-src that referenced this issue Aug 24, 2022
This was introduced in the commit that added the random extension:
4d8dd8d.

Resolves phpGH-9415
TimWolla added a commit that referenced this issue Aug 24, 2022
* Fix rand_range32() for umax = UINT32_MAX

This was introduced in the commit that added the random extension:
4d8dd8d.

Resolves GH-9415

* [ci skip] Rename `$r` to `$randomizer` in gh9415.phpt

* Make gh9415.phpt deterministic

* Make gh9415.phpt compatible with 32-bit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant