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

Implicit conversion from float ... to int loses precision (PHP 8.1) #59

Open
diggy opened this issue Oct 27, 2022 · 3 comments
Open

Implicit conversion from float ... to int loses precision (PHP 8.1) #59

diggy opened this issue Oct 27, 2022 · 3 comments

Comments

@diggy
Copy link

diggy commented Oct 27, 2022

Error with PHP 8.1.11 on this line

return (($value * $this->prime) & $this->max) ^ $this->xor;
, e.g.

Implicit conversion from float 3.802099463828355E+21 to int loses precision

@jenssegers
Copy link
Owner

I'm not fully up to date with the recent changes in PHP versions. Would casting everything explicitly to (int) fix the warning?

Would you be up for making a PR?

@diggy
Copy link
Author

diggy commented Oct 27, 2022

@jenssegers I'm not sure, some quick Googling seems to indicate that explicit casting or conversion is needed, but I wouldn't want to make the call and possibly break things here :)

@MissCoraline
Copy link

MissCoraline commented May 14, 2024

maybe the real reason is that you tried to encode a number bigger than maxid ? actually, you should not do that, otherwise you won't be able to decode from encoded value.

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

3 participants