|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectutil.Num2Str
public class Num2Str
a simple class to format numbers to a string in a way that I like--limited significant digits, scientific notation if they are too large or small. Decimal Format is just too inflexible
Field Summary | |
---|---|
static double |
LOG10
the natural logarithm of 10, for calculating log base 10 |
static java.lang.String |
MAX_STRING
a String that is larger than anything produced by format(double)
using the default number of digits. |
Constructor Summary | |
---|---|
Num2Str()
Creates a new instance of Num2Str with 3 significant digits after the decimal |
|
Num2Str(int numDigits)
Creates a new instance of Num2Str with a set number of significant digits. |
Method Summary | |
---|---|
java.lang.StringBuffer |
format(double d)
format a number. |
static java.lang.String |
formatNumber(double d)
static method that uses the default number of digits |
static java.lang.String |
formatNumber(java.lang.Object value)
static method that uses the default number of digits |
java.lang.String |
maxString()
returns a string that is larger than any number that will be produced. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double LOG10
public static final java.lang.String MAX_STRING
format(double)
using the default number of digits.
maxString()
,
Constant Field ValuesConstructor Detail |
---|
public Num2Str()
public Num2Str(int numDigits)
numDigits
- the number of significant digits after the decimal
(numDigits + 1) total
java.lang.IllegalArgumentException
- if numDigits <= 0Method Detail |
---|
public java.lang.StringBuffer format(double d)
public java.lang.String maxString()
format(double)
Assumes that "#" is larger than any digit.public static java.lang.String formatNumber(double d)
d
- the number to format
for the details of formatting
public static java.lang.String formatNumber(java.lang.Object value)
value
- an Object (that must be a Number) to format
java.lang.ClassCastException
- if value is not a Numberfor the details of formatting
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |