public static double Pow( // https://msdn.microsoft.com/en-us/library/system.math.pow(v=vs.110).aspx
double x,
double y
)

You could piggy back on the above; keep in mind that exceptions are possible.

public static decimal DecimalPower(decimal x, decimal y)
{
Double X = (double)x;
Double Y = (double)y;
return (decimal)System.Math.Pow(X, Y);
}

edit: example

void Main()
{
Decimal p = (Decimal)Math.Sqrt(2.0);
Console.WriteLine(p);
Decimal y = 2.0M;
Console.WriteLine(DecimalPower(p,y));
}

output:

1.4142135623731
2.00000000000001

end edit.

B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it

B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it

Member

158 Points

517 Posts

## Math.pow with decimals

Jan 27, 2015 09:43 PM|neoaguil17|LINK

Hello

I need to a create function:

Star

14297 Points

5797 Posts

## Re: Math.pow with decimals

Jan 27, 2015 11:55 PM|gerrylowry|LINK

@neoaguil17

Here is the definition for System.Math.Pow

You could piggy back on the above; keep in mind that exceptions are possible.

edit:exampleoutput:

end edit.B-) Gerry Lowry, Chief Training Architect,Paradigm MentorsLearning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do itStar

9555 Points

2784 Posts

## Re: Math.pow with decimals

Feb 02, 2015 09:57 PM|Paul Linton|LINK

1) What is it that you do not know how to do?

2) Do you know how to write a method that returns a result?

3) Can you write a method that adds two numbers?

4) Is this an exercise from your text book or an assignment from your tutor?

5) Have you done the previous exercises?

freepdf.Star

14297 Points

5797 Posts

## Re: Math.pow with decimals

Feb 04, 2015 01:26 PM|gerrylowry|LINK

@neoaguil17

Archer Wang had marked LINK as the answer to your O.P.; you chose to unmarked it.

neoaguil17, please explain why you are not satisfied with LINK so that your peers here at forums.asp.net can fine tune your answer.

P.S.: please read http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer

B-) Gerry Lowry, Chief Training Architect,Paradigm MentorsLearning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it