A very scary for loop

This commit is contained in:
Anthony Wang 2021-04-29 20:40:27 +00:00 committed by GitHub
parent 2afb334484
commit ed81135660
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

9
fast-pow/pow.cpp Normal file
View 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;
}