Skip to content

Oberserved rounding effects in cyrb53a #22

Answered by bryc
goto40 asked this question in Q&A
Discussion options

You must be logged in to vote

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-bit Number 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 using 4294967296n * BigInt(h2) + BigInt(h1).

The 53-bit transform is just an alternative way of using h1 and h2 (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…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by goto40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants