wt.clients.widgets
Class NumericToolkit

java.lang.Object
  extended bywt.clients.widgets.NumericToolkit

public class NumericToolkit
extends Object


Field Summary
private static char DECIMAL_SEPARATOR
           
private static char EXPONENT_CHAR
           
private static DecimalFormatSymbols formatSymbols
           
private static char GROUPING_SEPARATOR
           
static int MAX_SIG_FIGS
           
private static char MINUS_SIGN
           
private static char ZERO_DIGIT
           
 
Constructor Summary
private NumericToolkit()
           
 
Method Summary
static int countSigFigs(String valueString)
          Returns the number of significant figures that exist in the specified string representation of a floating point number.
static int countSigFigs(String valueString, Locale locale)
          Returns the number of significant figures that exist in the specified string representation of a floating point number.
static String doubleToString(double doubleValue)
          Returns a string representation of the specified double rounded to non-zero digits.
static String doubleToString(double doubleValue, int numDigits)
          Returns a string representation of the specified double rounded to the specified number of digits.
static String doubleToString(double doubleValue, int numDigits, Locale locale)
          Returns a string representation of the specified double rounded to the specified number of digits.
static String doubleToString(double doubleValue, Locale locale)
          Returns a string representation of the specified double rounded to non-zero digits.
static String makeLegalString(String stringValue)
           
static String makeLegalString(String stringValue, Locale locale)
           
static double roundingEquivalent(double doubleValue, int roundingDigits, int roundingDirection)
          Returns the largest or smallest double that, when rounded to the specified number of digits, is equal to the specified double rounded to the same number of digits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SIG_FIGS

public static final int MAX_SIG_FIGS
See Also:
Constant Field Values

formatSymbols

private static final DecimalFormatSymbols formatSymbols

DECIMAL_SEPARATOR

private static final char DECIMAL_SEPARATOR

GROUPING_SEPARATOR

private static final char GROUPING_SEPARATOR

MINUS_SIGN

private static final char MINUS_SIGN

ZERO_DIGIT

private static final char ZERO_DIGIT

EXPONENT_CHAR

private static final char EXPONENT_CHAR
See Also:
Constant Field Values
Constructor Detail

NumericToolkit

private NumericToolkit()
Method Detail

countSigFigs

public static int countSigFigs(String valueString)
Returns the number of significant figures that exist in the specified string representation of a floating point number.

Parameters:
valueString - the string that represents the floating point number.
Returns:
the number of significant figures that exist in the specified string representation of a floating point number.

doubleToString

public static String doubleToString(double doubleValue,
                                    int numDigits)
Returns a string representation of the specified double rounded to the specified number of digits. If possible, the string is returned in floating point format. Otherwise, the string is returned in exponential format.

Parameters:
doubleValue -
numDigits -
Returns:
String

doubleToString

public static String doubleToString(double doubleValue)
Returns a string representation of the specified double rounded to non-zero digits. If possible, the string is returned in floating point format. Otherwise, the string is returned in exponential format.

Parameters:
doubleValue -
Returns:
String

roundingEquivalent

public static double roundingEquivalent(double doubleValue,
                                        int roundingDigits,
                                        int roundingDirection)
Returns the largest or smallest double that, when rounded to the specified number of digits, is equal to the specified double rounded to the same number of digits. If the specified rounding direction is -1, then the largest double is returned. If the specified rounding direction is 1, then the smallest double is returned. If the specified number of digits is less than 1 or greater than MAX_SIG_FIGS, then the number of digits that will be used in calculating the return value will be MAX_SIG_FIGS.

Parameters:
roundingDigits - the number of digits that will be considered when calculating the rounding equivalent.
roundingDirection - the rounding direction, up or down, that will be used when calculating the rounding equivalent.
doubleValue -
Returns:
the largest or smallest double that, when rounded to the specified number of digits, is equal to the specified double rounded to the same number of digits.

countSigFigs

public static int countSigFigs(String valueString,
                               Locale locale)
Returns the number of significant figures that exist in the specified string representation of a floating point number.

Parameters:
valueString - the string that represents the floating point number.
Returns:
the number of significant figures that exist in the specified string representation of a floating point number.

doubleToString

public static String doubleToString(double doubleValue,
                                    int numDigits,
                                    Locale locale)
Returns a string representation of the specified double rounded to the specified number of digits. If possible, the string is returned in floating point format. Otherwise, the string is returned in exponential format.

Parameters:
doubleValue -
numDigits -
Returns:
String

doubleToString

public static String doubleToString(double doubleValue,
                                    Locale locale)
Returns a string representation of the specified double rounded to non-zero digits. If possible, the string is returned in floating point format. Otherwise, the string is returned in exponential format.

Parameters:
doubleValue -
Returns:
String

makeLegalString

public static String makeLegalString(String stringValue,
                                     Locale locale)

makeLegalString

public static String makeLegalString(String stringValue)