nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
938 stars 134 forks source link

pow() tweaks and a compile-time pow() #265

Closed ts826848 closed 3 years ago

ts826848 commented 3 years ago

This has a little bit of cleaning up my previous pow() PR and also adds a pow() that uses a compile-time exponent.

ts826848 commented 3 years ago

Fun fact: MSVC appears to produce an absolutely astounding amount of assembly for this particular compile-time pow(), the vast majority of which are seemingly pointless instantiations of pow_acc. In this case, pow<1024> caused MSVC to generate instantiations for pow_acc<536870911, double>, pow_acc<9007199254740991,double>, and pow_acc<-1025,double>, among many, many others.

Luckily, the actual function f(double) generated the expected assembly. The rest was certainly a surprise, though.

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 0.0% when pulling 2287967508fa6ca41926f2733644d669be129884 on ts826848:pow-tweaks into 791dab538f5dc890b031edac7e2a9b21d7436bf5 on nholthaus:v3.x.