How to import floor, ceil, etc with MIDP?

Discussion in 'Java' started by SpaceCowboy, Aug 13, 2003.

  1. SpaceCowboy

    SpaceCowboy Guest

    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
     
    SpaceCowboy, Aug 13, 2003
    #1
    1. Advertising

  2. SpaceCowboy

    pete kirkham Guest

    SpaceCowboy wrote:

    > 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
     
    pete kirkham, Aug 13, 2003
    #2
    1. Advertising

  3. SpaceCowboy

    Roedy Green Guest

    On Wed, 13 Aug 2003 21:03:20 GMT, "SpaceCowboy" <>
    wrote or quoted :

    >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 );


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 14, 2003
    #3
  4. SpaceCowboy

    Roedy Green Guest

    On Thu, 14 Aug 2003 02:26:21 GMT, "SpaceCowboy" <>
    wrote or quoted :

    >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 )

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 14, 2003
    #4
  5. SpaceCowboy

    Josef Garvi Guest

    Roedy Green wrote:
    >
    > 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
     
    Josef Garvi, Aug 14, 2003
    #5
  6. SpaceCowboy

    SpaceCowboy Guest

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

    SpaceCowboy

    "Roedy Green" <> wrote in message
    news:...
    > On Thu, 14 Aug 2003 08:16:02 +0200, Josef Garvi
    > <> wrote or quoted :
    >
    > >And java.lang.Math for MIDP contains no floor function.

    >
    > Arrgh. Sorry about that. Too bad they did not use different class
    > names.
    >
    > We may need a special newsgroup for MIDP and other mini-Javas since
    > that knowledge is specialised.
    >
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    SpaceCowboy, Aug 14, 2003
    #6
  7. SpaceCowboy

    Josef Garvi Guest

    Roedy Green wrote:
    >
    > 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
     
    Josef Garvi, Aug 15, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fahad
    Replies:
    1
    Views:
    598
    Andrew Thompson
    Aug 8, 2005
  2. Replies:
    9
    Views:
    761
    Andrey Tarasevich
    Oct 23, 2006
  3. zlotawy

    ceil and floor

    zlotawy, Sep 15, 2007, in forum: VHDL
    Replies:
    4
    Views:
    703
  4. john.swilting

    use POSIX qw(ceil floor)

    john.swilting, Apr 21, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    177
    john.swilting
    Apr 26, 2007
  5. RobG
    Replies:
    6
    Views:
    239
Loading...

Share This Page