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

Count combinations returns NAN #10

Closed
dmitry-zaporozhan opened this issue May 28, 2018 · 3 comments
Closed

Count combinations returns NAN #10

dmitry-zaporozhan opened this issue May 28, 2018 · 3 comments
Assignees

Comments

@dmitry-zaporozhan
Copy link

Consider using bcmath in factorial calculations.
This code results in NAN

$p = new Combinations(range(1, 200), 2);
var_dump($p->count());

While this code results in 19900

$p = new Combinations(range(1, 200), 2);
var_dump(count($p->toArray()));
@drupol drupol self-assigned this May 28, 2018
@drupol
Copy link
Owner

drupol commented May 28, 2018

thanks, will check this out asap.

@drupol
Copy link
Owner

drupol commented May 28, 2018

This is indeed a confirmed bug.

I'm still wondering if I should use count($p->toArray()) to get the count or rely on a mathematical formula.
The issue while using the first proposition is that it needs to compute the whole solutions array.
The issue using the last proposition is that it might generate huge numbers and then they gets simplified (root of the issue you reported).

I'm still wondering what to do.

drupol added a commit that referenced this issue May 29, 2018
drupol added a commit that referenced this issue May 29, 2018
drupol added a commit that referenced this issue May 29, 2018
drupol added a commit that referenced this issue May 29, 2018
Issue #10: Do not use a formula to compute the count.
@drupol
Copy link
Owner

drupol commented May 29, 2018

Fixed, tagged a new version 1.3.3 ready for use.

Thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants