-
Thank you for sharing your great work! I observed that we have a small rounding effect in the last multiplication of return 2097152 * (h2 >>> 0) + (h1 >>> 11);; with return BigInt(2097152) * BigInt((h2 >>> 0) + (h1 >>> 11)); yields slightly different values. I apologize if I have overseen this in the documentation, but I thought the algorithm was designed in order not to have rounding issues due to the precision of the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You're doing The multiply is doing a bitwise left-shift, i.e. Keep in mind, The 53-bit transform is just an alternative way of using Also I don't recommend using a) It's not finished. When it is finished, it will produce different results, so if you expect your cyrb53a function to be correct, you have to plan to update it in the future, or you'll have to just continue using the 'beta' version. |
Beta Was this translation helpful? Give feedback.
You're doing
(2097152) * (h2 + h1)
when it should be(2097152) * (h2) + (h1)
.The multiply is doing a bitwise left-shift, i.e.
h2 << 21
. We can't use the<<
operator because bitwise operations are bound to 32 bits, which prevents us from outputting a 53-bitNumber
as intended.Keep in mind,
BigInt
has some performance overhead, which can have an accumulative effect on large-scale simulations, and honestly you might as well use all 64 bits using4294967296n * BigInt(h2) + BigInt(h1)
.The 53-bit transform is just an alternative way of using
h1
andh2
(which is kind of required in JS); C users can (and should) just simply do(h2 << 32) | h1
. The way to verify implementations would be to simp…