unsigned long long int pow

前端 未结 2 857
心在旅途
心在旅途 2021-01-13 11:34

I have the following power function which operates on integers and it works fine:

int ipow( int base, int exp )
{
    int result = 1;
    while( exp )
    {
         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 12:15

    Your base variable is too small. Change it to unsigned long long int, like the others, since it holds numbers greater than 2^32.

提交回复
热议问题