Long ago, I was optimizing a hot-path in some game physics code which involved lots of Math.floor() and parseInt() operations. I came across a micr...
For further actions, you may consider blocking this person and/or reporting abuse
Damn! I had not idea this was a thing!
Thanks for the great read! 🔥
Thanks!
That's a very interesting little thing. Do you happen to have any concrete data (or general idea) as to how much it improves performance?
(I'm not trying to contest your point, I'm just curious)
At the time I first found it, I do remember comparing perf and finding it faster.
I just wrote a quick perf test, see the updated article!
Cheers! That is a considerable increase from
parseInt
indeed!It is a good operator if you want a function that truncates toward zero.
Amazing article! Thank you
I've been using double tilde ocassionally for a while, but I never knew about the single one!
I think bitwise operations are always a bad idea.
If someone can't read it and guess what it does, then it shouldn't be used.
You are right. It depends, as I said.
I used it because of perf gains I needed. Maybe a comment explaining the code line would be a good compromise for situations like this.
Super interesting! Thank you for the read!
On Firefox, Math.floor is actually faster by 23%.
woah,
i'm down for using this.
besides, it's obviously faster.
thank you for this.