Performance of bitwise operators in javascript

后端 未结 12 2377
难免孤独
难免孤独 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:16

    I use bitwise shift of zero in JS to perform quick integer truncation:

    var i=3.141532;
    var iTrunc=i>>0; //3
    

提交回复
热议问题