Forgive the large post of source code, but maybe this will help some of you that, like me, are fighting to find the missing Math functions from Java SE in ME. I ported the ones I needed from Sun's own FDLIBM C-library -- Sun should really provide the missing Math functionality as a standard extension to J2ME themselves for developers if it's not part of the device JVM. Google's Andriod is using the equivalent of Java5 -- Java ME needs to come out of the dark ages to compete.

Sun, or others, let me know if you'd like me to add more functions to this -- the exp, log, and pow were the most glaring omissions for implementing geographic projections like Mercator and Lambert.

I've battered this with millions of JUnit random number tests and it gives _exactly_ the same results as the Java SE JVM Math.exp, log, and pow methods since it is an exact port from the C-library underlying Java SE.

/**
* Return a to the power of b, sometime written as a ** b
* but not to be confused with the bitwise ^ operator.
* This in turn uses ieee7854_log(double).
*/
public static final double pow(double a, double b) {
return ieee754_pow(a, b);
}

Glad to hear this is helpful for others. I can't believe these weren't eventually included in the Java ME already. I'm adding methods as people need them and doing test comparison against the full Java SE Math method where they should match exactly.

I'll put acos/asin next on the list and will post an Announcement to the akmemobile.dev.java.net project when they're ready. Please use the code there not what's posted here.

I'm splitting the common Java ME libraries from akmemobilemaps at sourceforge.net to this project at dev.java.net to be closer to Java ME developers looking for sample code. I found it far too painful to get started with Java ME development so hopefully this helps other along the way.