PLEASE HELP - Does J2ME include java.lang.Math

C

cpptutor2000

I am trying to make a simple J2ME application that would do some
manipulation with trigonometric functions on floating point data, on a
handheld device. For prototyping purposes, I am using Sun
Microsystems' WTK 2.2, and the settings have CDLC 1.1. My source file
has the import:
import java.lang.Math;

However, I get error messages as:
Building "Test"
C:\WTK22\apps\Test\src\TestUtility.java:58: cannot resolve symbol
symbol : variable nu
location: class RecordUtility
for (int i = 1; i <= nu; i++)
^
C:\WTK22\apps\Test\src\TestUtility.java:70: cannot resolve symbol
symbol : method log (int)
location: class java.lang.Math
int nu = (int)(Math.log(n)/Math.log(2));
^
C:\WTK22\apps\Test\src\TestUtility.java:70: cannot resolve symbol
symbol : method log (int)
location: class java.lang.Math
int nu = (int)(Math.log(n)/Math.log(2));
^
3 errors
com.sun.kvem.ktools.ExecutionException
Build failed

I tried casting n as n11 = (double)n and then using this value, but it
has not helped.
Could some Java guru please suggest what a suitable solution might
be ? Any hints/suggestions would be greatly appreciated - thanks in
advance for your help.
 
L

Lew

I am trying to make a simple J2ME application that would do some
manipulation with trigonometric functions on floating point data, on a
handheld device. For prototyping purposes, I am using Sun
Microsystems' WTK 2.2, and the settings have CDLC 1.1. My source file
has the import:
import java.lang.Math;

You never need to import java.lang classes.
However, I get error messages as:
Building "Test"
C:\WTK22\apps\Test\src\TestUtility.java:58: cannot resolve symbol
symbol : variable nu
location: class RecordUtility
for (int i = 1; i <= nu; i++)
^

How was 'nu' declared at this point?
 
J

jestan

Hi cpptutor2000!

Math.log() is not available CLDC 1.1 , CLDC 1.1 supports floatingpoint
types, includes several more methods in java.lang.Math, but CLDC's
java.lang.Math is still a subset of the J2SE version of the
class.Please refer Java doc which came with the Wireless Tool Kit.

Have a look at static methods of Math class in CLDC 1.1

public final class Math extends java.lang.Object {

// Constants

public static final double E;
public static final double PI;

// Static methods

public static int abs(int a);
public static long abs(long a);
public static float abs(float a);
public static double abs(double a);
public static native double ceil(double a);
public static native double cos(double a);
public static native double floor(double a);
public static int max(int a, int b);
public static long max(long a, long b);
public static float max(float a, float b);
public static double max(double a, double b);
public static int min(int a, int b);
public static long min(long a, long b);
public static float min(float a, float b);
public static double min(double a, double b);
public static native double sin(double a);
public static native double sqrt(double a);
public static native double tan(double a);
public static double toDegrees(double angrad);
public static double toRadians(double angdeg);

}

I think, you have to use a third party library like MicroFloat (http://
www.dclausen.net/projects/microfloat/) to use J2SE (add, subtract,
multiply, divide, mod, comparisons, typecasts) as well as
java.lang.Math (sin, cos, exp, pow, log, etc.).

Jestan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top