Closed opensso closed 7 years ago
The original and reference implementation is a JS version. JS number limitation is (2^53 - 1)
. In the java implementation we used Long
because Integer
has a max value of (2^31 - 1)
. As Long
has a limitation of (2^63 - 1)
we have to limit the upper bound.
That's why we cannot accept values greater than JS.
Thanks for explanation. It would be nice to have ability to provide Max number as constructor argument.
Why don't use BigInt for Javascript to resolve the number max value in Javascript instead of use a more little number for java ?
We are just a port from JS version.
JS version is preparing the BigInt package and will support it with V2. Why don't make the MAX_NUMBER as options instead of final value.
This was a suprise to me as well, as the org.hashids.Hashids#encode(Long) method makes no mention of this, so on paper the interface supports any long.
This seems like something that should be on the javadoc. For random numbers, ThreadLocalRandom.current().nextLong(Hashids.MAX_NUMBER)
works well.
Hello,
I was looking into this great library for my project, but I quickly found undocumented limitation that this library doesn't support any number > 9007199254740992L. Could you please explain the reasoning behind this limitation?
ids.encode(new Random().nextLong()