Name

Math

Synopsis

The CLDC Math class is an extremely small subset of its J2SE counterpart, providing utility methods that work with int and long values. Most of the J2SE methods cannot be included because a CLDC VM does not provide for floating point arithmetic.

The abs() methods return the absolute value of an int or long pased as its argument. The max() method returns the larger of two ints or longs, while min() returns the smaller.

public final class Math {
// No Constructor
                    
// Public Class Methods
   public static int abs( int a);                                // strictfp
   public static long abs( long a);                              // strictfp
   public static int max( int a, int b);                         // strictfp
   public static long max( long a, long b);                      // strictfp
   public static int min( int a, int b);                         // strictfp
   public static long min( long a, long b);                      // strictfp
}

Get J2ME in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.