Archived

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

Cube Roots

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

Recommended Posts

How do you get the cube root of something? zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.

Share on other sites
try this, im a begginer at C++ kinda, but I think this would work...

    int cubeRoot(int a){int b = 3int c = 0;for(b=0; b<4; b++){c += a*a}return a;}

then use like

int x = cubeRoot(4);

I think that should work..

Edited by - uG on August 30, 2000 7:08:38 PM

Share on other sites
pow( x, .33 )?

in many cases, this will only work if x is positive.

Edited by - Antknei on August 30, 2000 7:10:30 PM

Share on other sites
try this, im a begginer at C++ kinda, but I think this would work...

    int cubeRoot(int a){int b = 3int c = 0;for(b=1; b<4; b++){c += a*a}return a;}

then use like

int x = cubeRoot(4);

I think that should work..

Share on other sites
Your equation ends up with c = 3a^2. but it returns a, which you don''t change. Am I missing something, or did you mistype something?

Share on other sites
Like Antknei was saying, to get the nth root of a number x, use pow(x, 1/n). As far as I know, the only time you get an error returned from this function is when you try to raise zero to a negative power, as this would be equivalent to division by zero.

-Ironblayde
Aeon Software

Share on other sites
Or you could do it using the mathemathical equasion:

n root of x = exp(log(x)/n)

Dormeur

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633734
• Total Posts
3013590
×