Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
March 11th, 2003, 11:45 PM
 andy3109
Contributing User

Join Date: Nov 2002
Posts: 421
Time spent in forums: 15 h 46 m 21 sec
Reputation Power: 12

If I wanted to calculated the radical of 5/4 how would i do that in C++? Not sure of the syntax and I don't believe math.h has a radical function. Thanks.
-andy
__________________
hmmm...

#2
March 11th, 2003, 11:53 PM
 andy3109
Contributing User

Join Date: Nov 2002
Posts: 421
Time spent in forums: 15 h 46 m 21 sec
Reputation Power: 12
nevermind..im an idiot..its in math.h

#3
March 12th, 2003, 12:00 AM
 dwise1_aol
Contributing User

Join Date: Jan 2003
Location: USA
Posts: 6,883
Time spent in forums: 3 Months 1 Day 15 h 47 m 56 sec
Reputation Power: 2199
I'm not sure what you are asking here. By "calculat[ing] the radical", I assume that you want to find any real root of any floating-point value.

The pow(double x, double y) function in math.h should do it, along with its long double cousin, powl(). They both calculate the value of x raised to the y power.

Pardon the explanation, but I don't know how far you had gotten in math. To take the n-th root of a number, x, you raise x to the 1/n power. Eg, the square root of x would be pow(x,0.5) and the 10th root of x would be pow(x,0.1).

Otherwise, you could use the log() and exp() functions:
x_to_the_n = exp(log(x)/n);

 Viewing: Dev Shed Forums > Programming Languages > C Programming > radicals?