Ok, I've been trying to to find a way of using trig functions in my code, but I've been having nothing but problems. I've been using the henson Float class, available at: http://henson.newmail.ru/j2me/Float.htm
But the answers it gives me for the cos and sin functions are pure nonsense. I'm trying to convert the degrees to radians and then run the cos and sin functions on them. It seemed to work fine for a test value of 60 degrees (1.047 radians), giving me the approximately correct results of cos 1.047 = 0.5001 and sin 1.047 = 0.866 But when I try it with anything else the results are utterly wrong. For example 45 degrees (2 radians), instead of getting 0.707 for both it gives me cos 2 = -0.416 and sin 2 = 0.909 ?
Why does it work for only the one value ? Has anybody got this float class to work, ever ? Has anybody got any alternatives ? Please help me , I'm getting annoyed and desperate for a solution. I've also tried using MathFP, but that kept giving me wrong class name error.
Why not use the toRadians(double angdeg) method of the java.lang.Math class ? There also happen to be cos(double a) and sin(double a) methods in this class. What is the reason for calculating using floats instead of doubles ?
You are correct that CLDC 1.0 and MIDP 1.0 don't have support for float or double values. I haven't worked with J2ME for a while, though, so I don't know if MIDP 2.0 (or more recent versions) have support for double or not.
After a little more search, I found out that it is CLDC 1.0 that specifically rules out floating point arithmetic. Since MIDP is built on CLDC, it just inherits this limitation. Perhaps more recent versions of CLDC have introduced floating point arithmetic, though.
Sorry that this doesn't answer your quesiton completely, but I just wanted to clarify that such limitations DO exist.