I don't know J2ME well enough to know, but do you have Math.log()
and Math.exp()
?
Then you can simply use this relation:
x^y = exp(y * log(x))
If you don't have the aforementioned two functions, then you should start by implementing those. As far as I know, the above relation is the only reasonable way to compute x^y
.
Update: I see the paper linked in kusman's answer shows an alternative way to do pow
using the idea of a fractional exponent. Quite cool! But the paper also shows the "normal" way to do things via multiplication of the log, and shows you how to implement Taylor series for exp()
and log()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…