View Single Post
Old 10-27-2005, 09:46 PM   #8 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Quit being lazy. If you can't get the library function to work, write your own pow() function. Programming is about problem solving. Ideally, we want to avoid duplication but, the function isn't that hard to write.
Code:
int pow ( int base, int exp ) {
     if ( exp <= 0 ) {
	  //not mathematically correct but negative exponents won't return an int anyway
	  return 1; 
	       }
     else {
	  int i;
	  int result = 1;
	  
	  for( i = 0; i < exp; i++ ) {
	       result = result * base;
	  }

	  return result;
     }
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote