Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

PLEASE HELP - Does J2ME include java.lang.Math

Thread view: 
cpptutor2000@yahoo.com - 28 Mar 2008 00:57 GMT
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.
Lew - 28 Mar 2008 07:53 GMT
> 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"
[quoted text clipped - 3 lines]
>     for (int i = 1; i <= nu; i++)
>                          ^

How was 'nu' declared at this point?

> C:\WTK22\apps\Test\src\TestUtility.java:70: cannot resolve symbol
> symbol  : method log (int)
[quoted text clipped - 9 lines]
> com.sun.kvem.ktools.ExecutionException
> Build failed

Signature

Lew

jestan - 28 Mar 2008 09:30 GMT
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.
cpptutor2000@yahoo.com - 28 Mar 2008 14:47 GMT
Thank you very much for the URL to the microfloat package.

> Hi cpptutor2000!
>
[quoted text clipped - 42 lines]
>
> Jestan.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.