"pow(x, 2.0)": argh
-
-
Replying to @rygorous
On my list of Lua optimizations there’s “people use x^2 and x^0.5 without knowing what they’re getting into, need to specialize to sqrt/sqrt”
2 replies 0 retweets 3 likes -
Beware, you’ll eventually end up implementing the trigonometric function cache that all JS engines implemented to game the SunSpider benchmarks :)
1 reply 0 retweets 1 like -
Thankfully we don’t have a direct competition so no benchmarks to game :) have not seen any trig heavy code I care about yet. But was surprised to see people use ^2 as a shortcut.
1 reply 0 retweets 1 like -
I would argue for including a power operator in most langs that you expect people to write computations in simply so it's natural to make this kind of optimization.
1 reply 0 retweets 1 like -
It's useful (and standard) notation and making people jump through hoops to use their own "square" fn or expecting them to know which integer/fractional powers can be computed quickly (and how) just seems bonkers to me
1 reply 0 retweets 0 likes
GCC at least does the optimization: https://gcc.godbolt.org/z/Sc6qd7
-
-
the mingw version doesn't seem to :/
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.