com.pentec.util
Class AFormat

java.lang.Object
  extended by com.pentec.util.AFormat

public class AFormat
extends java.lang.Object

AFormat is the ADAPT number formatter. AFormat instantiates standard Java text formatters, and uses its own format method to select which formatter to use based on the input.

Author:
Pender Technology

Field Summary
private static java.text.NumberFormat numFormatter
          Java NumberFormat formatter for floating decimal point
private static java.text.DecimalFormat scientificFormatter
          Java DecimalFormat formatter for scientific notation
 
Constructor Summary
AFormat()
           
 
Method Summary
static java.lang.String format(double d)
          Convert a double precision number to a string with 2 digits after the decimal point.
static java.lang.String format(double d, int iNumFracDigits)
          Return a string for displaying the specified number, with a variable number of digits after the decimal point.
static java.lang.String format(double d, int iNumFracDigits, boolean useE)
          Return a string for displaying the specified number, with a variable number of digits after the decimal point.
static java.lang.String formatE(double d, int iNumFracDigits)
          Return a string for displaying the specified number, with a variable number of digits after the decimal point, using scientific notation.
static java.lang.String toBinString(short s)
           
static java.lang.String toHexString(short s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numFormatter

private static java.text.NumberFormat numFormatter
Java NumberFormat formatter for floating decimal point


scientificFormatter

private static java.text.DecimalFormat scientificFormatter
Java DecimalFormat formatter for scientific notation

Constructor Detail

AFormat

public AFormat()
Method Detail

format

public static java.lang.String format(double d)
Convert a double precision number to a string with 2 digits after the decimal point. Invoking format(d) is equivalent to invoking format(d,2). See format(double,int) for more information.

Parameters:
d - the double precision number to format
Returns:
the formatted string

format

public static java.lang.String format(double d,
                                      int iNumFracDigits)
Return a string for displaying the specified number, with a variable number of digits after the decimal point. For numbers less than -10000 and greater than +100000, and for numbers between -0.1 and +0.1, a scientific notation format is used. For all other numbers a fixed point format is used. If the number is 0.0, the string "0.0" is returned.

Parameters:
d - the double precision number to format
iNumFracDigits - the number of digits after the decimal point
Returns:
the formatted string

format

public static java.lang.String format(double d,
                                      int iNumFracDigits,
                                      boolean useE)
Return a string for displaying the specified number, with a variable number of digits after the decimal point. If useE is false, a fixed point format is usd for all numbers. If useE is true, then for numbers less than -10000 and greater than +100000, and for numbers between -0.1 and +0.1, a scientific notation format is used.

Parameters:
d - the double precision number to format
iNumFracDigits - the number of digits after the decimal point
useE - if true use scientific notation for small and large numbers
Returns:
the formatted string

formatE

public static java.lang.String formatE(double d,
                                       int iNumFracDigits)
Return a string for displaying the specified number, with a variable number of digits after the decimal point, using scientific notation.

Parameters:
d - the double precision number to format
iNumFracDigits - the number of digits after the decimal point
Returns:
the formatted string

toBinString

public static java.lang.String toBinString(short s)

toHexString

public static java.lang.String toHexString(short s)