Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2008

    Math.round in J2me


    In j2me it does not support math as i want to implement this codes it came out error

    public void setFrameRate(float fps) {
    if (fps != 0f) {
    delay = Math.round(100f / fps);

    I google in and found soulution out a Java floating point emulation library for MIDP devices , with that i am able to use the Math in j2me?

    If not any suggestion for me to solve that error?

    Thank in advance =)

  2. #2
    Registered User
    Join Date
    Nov 2008

    Re: Math.round in J2me

    Hi i found the solution, but by using MathSupport.round() will it be the same as Math.round() ?

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2007
    Rome, Italy

    Re: Math.round in J2me

    Hi shirodas,

    to have rounding in Java ME you have two choices:

    * use one of the available APIs (like the one you're probably mentioning in your second post): MicroFloat is one of these

    * implement it by your own (you can find many available code samples around, like this)

    Hope it helps,

  4. #4
    Registered User
    Join Date
    Mar 2011

    Re: Math.round in J2me

    Round in Java ME, e.g. in J2ME

    The code below is example, method that shows how to
    round a double to n decimals:

    private double round(double num,int numDecim){
    long p=1;
    //next line – calculate pow(10,numDecim)
    for(int i=0;i<numDecim;i++)p*=10;

    return (double)(int)(p*num+0.5)/p;

    You may use double p=1.0; or p*=10.0; instead.

    There are different solutions, bat I hope this can help.

    Ljubisa Cvetic

Similar Threads

  1. J2ME or C++ for VoIP on Mobile
    By sandeepkumar03 in forum VoIP
    Replies: 4
    Last Post: 2009-02-02, 10:28
  2. J2ME or C++ for VoIP on Mobile Phone
    By sandeepkumar03 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-11-13, 20:14
  3. How can the WAP browser communicate to J2ME application?
    By hbfornies in forum Mobile Java General
    Replies: 20
    Last Post: 2007-03-02, 16:32
  4. J2ME Polish Version 1.0 RC6
    By enough in forum Mobile Java General
    Replies: 1
    Last Post: 2004-07-20, 11:25
  5. TinyLine SVG Minute Toolkit for J2ME: version 1.4 released
    By girow in forum Mobile Java General
    Replies: 0
    Last Post: 2003-05-05, 16:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts