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

Confusion about supported integer range #64

Closed
patrickfav opened this issue Apr 8, 2019 · 3 comments
Closed

Confusion about supported integer range #64

patrickfav opened this issue Apr 8, 2019 · 3 comments

Comments

@patrickfav
Copy link

patrickfav commented Apr 8, 2019

The doc says:

decodable hashes from unsigned (long) integers

but then it says

All (long) integers need to be greater than or equal to zero

And the implementation caps the max number to 2^53 (0-9,007,199,254,740,992)

https://github.com/10cella/hashids-java/blob/162a263c8007652472bf1821a26d33190730f8a5/src/main/java/org/hashids/Hashids.java#L24


  • IF unsigned 64-bit integer was support, it would accept: 2^64 or 0 - 18,446,744,073,709,551,616 (1.8x10^19)
  • IF signed 64-bit integer was support from zero up, it would accept: 2^63 or 0 - 9,223,372,036,854,775,807 (9.2x10^18)

You currently support 53 bit long integers - I can only assume that is a bug? Java's primitives are always signed, so you have about 2^63 values in the plus and minus range. The most logical range would be 2^63 if you only want to support from 0 up and not make the caller convert to unsigned longs?

@0x3333
Copy link
Collaborator

0x3333 commented Apr 8, 2019

This is to be compatible with the original implementation.

Read Limitations on Readme.md, https://github.com/10cella/hashids-java#limitations

@0x3333 0x3333 closed this as completed Apr 8, 2019
@patrickfav
Copy link
Author

Ah I see, thanks. Maybe adapt the readme, because 'decodable hashes from unsigned (long) integers' is very misleading as it does not mean unsigned in the primitive type sense, but just that negative numbers are not allowed, it actually uses signed longs.

@0x3333
Copy link
Collaborator

0x3333 commented Apr 9, 2019

Feel free to create a PR, would help. Thanks!

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