Re: Power arithmetic function to C#
- From: "SunYour" <sunyour@xxxxxxxxxxx>
- Date: 29 Mar 2006 22:42:53 -0800
Thank you all, here is my c# contribution:
public static double MathPower(double basenum, double exponent)
{
if(exponent == 0)
return 1;
else if(basenum == 0 && exponent > 0)
return 0;
else if((basenum - (int)basenum) == 0 && Math.Abs(exponent)
<= int.MaxValue)
return Math.Pow(basenum, (int)Math.Truncate(exponent));
else
return Math.Exp(exponent * Math.Log(basenum, Math.E));
}
(base is a keyword in c#)
/Magnus
.
- Follow-Ups:
- Re: Power arithmetic function to C#
- From: Maarten Wiltink
- Re: Power arithmetic function to C#
- References:
- Power arithmetic function to C#
- From: SunYour
- Re: Power arithmetic function to C#
- From: Tom de Neef
- Re: Power arithmetic function to C#
- From: Hanford Carr
- Re: Power arithmetic function to C#
- From: Maarten Wiltink
- Power arithmetic function to C#
- Prev by Date: Hint in menu
- Next by Date: Re: Power arithmetic function to C#
- Previous by thread: Re: Power arithmetic function to C#
- Next by thread: Re: Power arithmetic function to C#
- Index(es):