net.ctdp.rfdynhud.util
Class NumberUtil

java.lang.Object
  extended by net.ctdp.rfdynhud.util.NumberUtil

public class NumberUtil
extends java.lang.Object

The NumberUtil keeps static methods to format numbers.

Author:
Marvin Froehlich (CTDP)

Constructor Summary
NumberUtil()
           
 
Method Summary
static java.lang.String delta(float i)
           
static java.lang.String delta(int i)
           
static java.lang.String formatFloat(float f, int numDecPlaces, boolean forceFractions)
          Formats the given float to a String with the specified number of decimal places.
static java.lang.String formatFloat(float f, int numDecPlaces, boolean forceFractions, boolean forceSign)
          Formats the given float to a String with the specified number of decimal places.
static java.lang.String pad2(int number)
           
static int roundUpPower2(int v)
          Gets the next greater power-of-two for the given number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtil

public NumberUtil()
Method Detail

pad2

public static final java.lang.String pad2(int number)

formatFloat

public static final java.lang.String formatFloat(float f,
                                                 int numDecPlaces,
                                                 boolean forceFractions,
                                                 boolean forceSign)
Formats the given float to a String with the specified number of decimal places.

Parameters:
f - the number to format
numDecPlaces - the maximum number of decimal places
forceFractions - always format with maximum number of fractions?
forceSign - always show the sign?
Returns:
the formatted String.

formatFloat

public static final java.lang.String formatFloat(float f,
                                                 int numDecPlaces,
                                                 boolean forceFractions)
Formats the given float to a String with the specified number of decimal places.

Parameters:
f - the number to format
numDecPlaces - the maximum number of decimal places
forceFractions - always format with maximum number of fractions?
Returns:
the formatted String.

roundUpPower2

public static final int roundUpPower2(int v)
Gets the next greater power-of-two for the given number.

Parameters:
v - the value to round up
Returns:
the next greater power-of-two for the given number.

delta

public static final java.lang.String delta(int i)

delta

public static final java.lang.String delta(float i)