Alex Rivera | Logout

Raising a decimal to a power of decimal?

Asked 2009-01-09T18:30:11.593
30

The .net framework provides in the Math class a method for powering double. But by precision requirement I need to raise a decimal to a decimal power [ Pow(decimal a, decimal b) ]. Does the framework have such a function? Does anyone know of a library with this kind of function?

Edit
Report

1 Answer

-5

Are you sure you actually want to do this? A decimal multiply is about 40 times slower than double's, so I'd expect a decimal Math.Pow() to be practically unusable.

If you expect only integer powers, though, I suggest you use the integer-based power algorithm that was already discussed here on SO.

answered 2009-01-09T18:36:39.227

Your Answer