Magnus wrote:

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));

}

It doesn't look to me like that does anything that Math.Pow doesn't do.

The Math.Pow is the same method as the Delphi-method IntPow

No, it's not. Math.Pow copes with floating point exponents just fine.

Could you give an example where just using Math.Pow doesn't do what you

want it to? Here's an example showing Math.Pow giving the same answer

as MathPower for non-integral values:

using System;

class Test

{

static void Main()

{

Console.WriteLine (MathPower (15.2, 2.3));

Console.WriteLine (Math.Pow (15.2, 2.3));

}

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));

}

}

Jon