External Links

Floating Point Support in Java ME

Anyone who has been writing Java ME (J2ME) applications for a while has probably run into one of the more frustrating limitations of the platform, lack of support for the floating point primitive types: float and double. More accurately, there is no floating point support in CLDC 1.0. If you can, use CLDC 1.1, which does have floating point support. If that’s not a viable option, another possibility is to use one of the fixed point math libraries that are freely available, or to roll your own solution.

One popular third-party library is MathFP, which according to the author is free for non-commercial use. Note, however, that every operation is a method call; that can turn into a lot of overhead. If you are writing an application where performance is a major concern (i.e. video games), your best bet is to roll your own fixed point math code, and implement it inline rather than through method calls.

The following article provides some good examples of using inline fixed point arithmetic in a Java application: Optimizing Fixed Point (FP) Math with J2ME

Bookmark this Post

2 Responses to “Floating Point Support in Java ME”

  1. Sebas86 Says:

    Thanks for that information. I need floating point support to make a small project. :)

  2. man Says:

    Hi,
    I am using Netbeans 6.9 with java ME 3.0 SDK.
    Do you know how to have float/double input field on visual midlet form.
    TextField type NUMERIC will only be integer, I need float.
    Will you please help me?

Leave a Reply