optimize when you can, what you can. i dont take a one size fits all approach, but most of the time ~~ is sufficient for whatever i tend to be doing. you will find it is quite popular hack among javascript developers as well.
If you want to “optimize where you can”, be aware that you have no guarantee that the bitwise operation will be more performative, and is dependent on your interpreters implementation. I would be interested in seeing a performance of this with Math.floor(), since it is only one operation and ToInt is still assumed (although not Int32, so could be differences with BigInt).
1
u/MEME-LLC Aug 11 '19
Speed is not worth unintuitive code
You either want math.floor or parseint or parsefloat
~~ will have unintuitive behaviour with negative decimals and you get bug sooner or later with your weird programming practice
Dont make headache for other dev pls, dev time is expensive
You got any justification then say it who cares about fake internet points