lemire / FastBitSet.js

Speed-optimized BitSet implementation for modern browsers and JavaScript engines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

question: 0 | 0

missinglink opened this issue · comments

Hi Daniel,

Apologies for opening an issue for this as it's more of a question for which I wasn't able to find an answer online.
In this code you use an unusual convention of initialising variables with 0 | 0, example

What is the purpose of this? I'm assuming it has a performance benefit but I can't imagine what since it seems unintuitive to me.

Please feel free to close this issue 🙏

Kind Regards
Peter

By default, numbers in javascript are binary64 numbers (floating-point numbers). We want to the the JavaScript compiler that our numbers are integers. The operator | returns returns a 32-bit integer, by definition.

Thanks for your response, makes sense but I wasn't aware that internally JS engines had multiple different numeric types as they are not exposed to the user.

Are you able to recommend some reading material which covers this topic where I can learn more without digging through the source code of V8 or whatever?

It would be best to raise the issue with the v8 community if v8 is your target. Generally speaking, the documentation of the behaviour of the JavaScript engine should be under the responsibility of the engine itself.