Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with calculation!

Status
Not open for further replies.

Smitty020

MIS
Jun 1, 2001
152
US
I'm trying to perform the following calculation:

y = (x ^(1/33)) -1)
where x = 14

I'm new to C#, but aware that there is no exponents.

How can I perform this calculation in C#?

Thanks for your help!

Smitty
 
Use the function:

Code:
System.Math.Exp(double d)
 
You can use:
Math.Pow(14,(1/33)) to get the result of 14^{1/33). There are also other math functions such as Math.Abs(..), Math.Sqrt(..) functions (methods of the class) in this Math class.
 
Actually, do not use
Code:
System.Math.Exp(double d)
unless you are wanting to raise e to a specified power!

Apologies for the incorrect function.
 
Don't know if it's an issue, but worth mentioning:

Make sure that your 1/33 is of type double. In C++ you had to make sure of this; I don't know if .NET handles the conversion for you... but if it doesn't, you may end up with x^0 every time... not many things more frustrating to figure out than that...

Ben
A programmer was drowning. Lots of people watched but did nothing. They couldn't understand why he yelled "F1!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top