Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dragonsimoto

how do u take a number to the power of

This topic is 6085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

equal = (num1^num2); i get zero for the answer when i do this with any number combos why dont it work? what is the correct way to do powers of? thanks, dragon

Share this post


Link to post
Share on other sites
Advertisement
now when i take the pow of some rather large powers, it gives me the same number but smaller pows work perfect. if u know this one let me know if not no big deal.

Share this post


Link to post
Share on other sites
perhaps the resulting big-ass number doesn''t fit in your data type? i think pow() returns a double, but are you putting it in an int or something?

Share this post


Link to post
Share on other sites
You could create your own function for a little coding practice...
Example:

float ComputeExponent(float base, float exponent)
{
int index;
float endresult = base;
for(index = 0; index < exponent - 1; index++)
endresult *= base;

return endresult;
}

Cheers,
-Jesse

| The Hitchhiker''''s Guide to Programming |
"That is not dead which can eternal lie,
And with strange aeons even death may die."
-H.P. Lovecraft

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!