如何在J2ME中获得数字的幂 [英] How to get the power of a number in J2ME
本文介绍了如何在J2ME中获得数字的幂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
J2ME power(double, double) math function implementation
我正在开发一个简单的j2me应用程序.我需要像在Java中的pow(double num1, double num2)
中那样获得数字的幂.
但是据我所知,j2me不支持此pow()方法.
任何有用的选项,不胜感激.
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.
推荐答案
public double pow(double num1, double num2) {
double result = 1;
for (int i = 0; i < num2; i++)
result *= num1;
return result;
}
这篇关于如何在J2ME中获得数字的幂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文