net.rim.device.api.util
Class MathUtilities

java.lang.Object
  |
  +--net.rim.device.api.util.MathUtilities

public final class MathUtilities
extends Object

Provides some basic numeric operations.


Method Summary
static int clamp(int low, int value, int high)
          Clamps provided value between a lower and upper bound.
static int wrap(int low, int value, int high)
          Wraps provided value around a lower and upper bound.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clamp

public static int clamp(int low,
                        int value,
                        int high)
Clamps provided value between a lower and upper bound.

Note: This method only produces sensible results if the lower bound is less than, or equal to, the higher bound.

Parameters:
low - Lower bound value.
value - Value to clamp.
high - Upper bound value.
Returns:
If the value is lower than the lower bound, this method returns the lower bound; if the value is higher than the higher bound, this method returns the higher bound; otherwise, this method returns the value itself.
Since:
JDE 4.0.2

wrap

public static int wrap(int low,
                       int value,
                       int high)
Wraps provided value around a lower and upper bound.

Note: This method only produces sensible results if the lower bound is less than, or equal to, the higher bound.

Parameters:
low - Lower bound value.
value - Value to wrap.
high - Upper bound value.
Returns:
If the value is lower than the lower bound, this method returns the higher bound; if the value is higher than the higher bound, this method returns the lower bound; otherwise, this method returns the value itself. This is the opposite of clamp()
Since:
JDE 4.0.2


Copyright 1999-2004 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.