aboutsummaryrefslogtreecommitdiff
path: root/fast-pow/pow.cpp
blob: 76c6702f0fd68f5443ca5986f6637b0d75b410bb (plain)
1
2
3
4
5
6
7
8
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;
}