Question: So I'm struggling to find out what this function is doing and what it looks like in terms of illustration. Does it have to do
So I'm struggling to find out what this function is doing and what it looks like in terms of illustration. Does it have to do with binary numbers?
* C++ has floating-point exponentiation named pow in the cmath library, * but no integer exponentiation. This is unsigned integer exponentiation. * @param base the base which is being raised to a power * @param exp the exponent to which to raise the base * @return base raised to the exp power */ uint ipow(uint base, uint exp) { if( base == 0 ) return 1; uint result = 1; while( exp > 0 ) { if( (exp & 1) == 1 ) result *= base; exp >>= 1; base *= base; } return result; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
