Search code examples
javajava-mepow

How to get the power of a number in J2ME


Possible Duplicate:
J2ME power(double, double) math function implementation

I'm developing a simple j2me application. There I need to get the power of a number as like as in the pow(double num1, double num2) in java. But as I got to know, j2me doesn't support to this pow() method. Any helpful option is appreciated.


Solution

  • public double pow(double num1, double num2) {
      double result = 1;
      for (int i = 0; i < num2; i++)
        result *= num1;
      return result;
    }