-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Return value of Jenssegers\ImageHash\Hash::toInt() must be of the type int, float returned #62
Comments
I think this only happens on 32bit systems? |
I'm executing it from a Dockerized application over a 64bit Mac. The container information is:
|
And is the PHP binary 32bit or 64bit? |
Is 64bit, check using this method:
|
|
I think you should drop the toInt method and allow access to the BigInteger objet directly, that's what I'm storing in my Doctrine entities with a custom type that unwraps to an unsigned bigint in SQL and it works pretty well. |
Any update to this? |
This library essentially needs 64bit PHP. As far as I can tell, this issue only occurs on 32-bit builds. |
According to Ghost's snippet, I'm running 64bit PHP. I'm running Ubuntu 20.04, with PHP7.4 from ondrej. |
PHP integers are signed integers, you can't fit a unsigned big integer generated by this hash inside a signed big integer unless you apply some dark magic like this: |
As a workaround I've replaced and add |
The way floats are store in memory doesn't make sense for this type of algorithm, you can't apply bitwise operations on float and expect them to behave the way integers or binary string do. The ideal way would be to never use numbers but instead only binary strings but you can't apply bitwise operator on strings in MySQL < 8. I think it might be supported in Postgres but I'm not sure. |
$this->toHex()
hexdec($this->toHex())
returned 1.8446743725834E+19 |
@4n70w4 same here, just wonder why the same hex value results different decimal values. |
Using
$hash->toInt()
in a image, the returned value is float, notinteger
The text was updated successfully, but these errors were encountered: