Performance of bitwise operators in javascript

后端 未结 12 2392
难免孤独
难免孤独 2020-12-14 08:33

One of the main ideas behind using bitwise operators in languages like C++/java/C# is that they\'re extremely fast. But I\'ve heard that in javascript they\'re very slow (ad

12条回答
  •  星月不相逢
    2020-12-14 09:15

    This is quite an old question, but no one seemed to answer the updated version.

    The performance hit that you get with JavaScript that doesn't exist in C/C++ is the cast from floating point representation (how JavaScript strores all of its numbers) to a 32 bit integer to perform the bit manipulation and back.

提交回复
热议问题