Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

pow without math.h

int pow(int base, int exp)
    {
      if(exp < 0)
        return -1;

        int result = 1;
        while (exp)
        {
            if (exp & 1)
                result *= base;
            exp >>= 1;
            base *= base;
        }

        return result;
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pow
ADD COMMENT
Topic
Name
6+2 =