How to import floor, ceil, etc with MIDP?

S

SpaceCowboy

I'm using Sun ONE Studio 4 update 1, Community Edition with Nokia
Developer's Suite integration. I'm developing a J2ME project with MIDP.

I wanted to use the java.math.floor() function, but whenver I tried to
import the java.math package, the compiler told me it couldn't be found. I
was finally able to import java.lang.math, but this has a bare minimum
mathematic functions. I'm still a newb, so can someone help me with this?

SpaceCowboy
 
P

pete kirkham

SpaceCowboy said:
I'm using Sun ONE Studio 4 update 1, Community Edition with Nokia
Developer's Suite integration. I'm developing a J2ME project with MIDP.

I wanted to use the java.math.floor() function, but whenver I tried to
import the java.math package, the compiler told me it couldn't be found. I
was finally able to import java.lang.math, but this has a bare minimum
mathematic functions. I'm still a newb, so can someone help me with this?

SpaceCowboy

In J2SE floor is a static method of the java.lang.Math object. If it's
not there in the J2ME version of the API, then it's nowhere.


Pete
 
R

Roedy Green

java.math.floor()

Java is case sensitive. The package is called java.lang. The class is
called java.lang.Math. You don't have to import java.lang.* classes.

So you can just say Math.floor( x );
 
R

Roedy Green

I found java.lang.math

There is no such thing. What you may have found was java.lang.Math

Java is case sensitive.
Unfortunately, it does not contain the floor function. I found out MIDP 1.0
doesn't support floating point, so it's a moot point. I wound up just
making a fixed point version of the function I was writing.


check out C:/j2sdk1.4.2/docs/api/java/lang/Math.html

It most definitively has a floor function.

static double floor( double )
 
J

Josef Garvi

Roedy said:
check out C:/j2sdk1.4.2/docs/api/java/lang/Math.html

It most definitively has a floor function.

static double floor( double )

Roedy, I think you are confusing things. They are talking about MIDP.
MIDP indeed doesn't support floats.
And java.lang.Math for MIDP contains no floor function.

--
Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty
 
S

SpaceCowboy

That would be awesome since all of my development right now is centered
around MIDP/J2ME.

SpaceCowboy
 
J

Josef Garvi

Roedy said:
Arrgh. Sorry about that. Too bad they did not use different class
names.

I think the reason is that the normal java.lang.Math contains all functions
from little brother MIDP + many more. (for sharing your code upwards)

We may need a special newsgroup for MIDP and other mini-Javas since
that knowledge is specialised.

Yes, that would be very useful!

--
Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top