A very scary for loop
This commit is contained in:
parent
2afb334484
commit
ed81135660
1 changed files with 9 additions and 0 deletions
9
fast-pow/pow.cpp
Normal file
9
fast-pow/pow.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
|
auto pw(auto b,int e){auto r=b;for(--e<<=1;e>>=1;r*=(e&1)*b,b*=b);return r;}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << pw(2, 4) << std::endl;
|
||||||
|
std::cout << pw(std::numbers::e, 2) << std::endl;
|
||||||
|
}
|
Reference in a new issue