org.freehep.util
Class ScientificFormat
- java.lang.Object
-
- java.text.Format
-
- org.freehep.util.ScientificFormat
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class ScientificFormat extends java.text.FormatThis code formats numbers in Scientific Notation. The input Number object is returned as a ScientificFormated string. There are two output styles: Pure and Standard scientific notation. Pure formatted numbers have precisely the number of digits specified by the significant digits (sigDig) parameter and always specify a Base 10 Exponential(E). Standard formated numbers have the number of digits specified by the significant digits (sigDig) parameter but will not have a Base 10 Exponential(E) if the number of digits in the mantissa <= maxWidth.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ScientificFormat()ScientificFormat(int sigDigit, int maxWidth, boolean SciNote)Sets the significant digits, maximum allowable width and number formatting style (SciNote == true for Pure formatting).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.Stringformat(double d)Format the number using scientific notationjava.lang.StringBufferformat(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Implementation of inherited abstract method.intgetMaxWidth()Returns the maximum allowable width of formatted number excluding any exponentialsbooleangetScientificNotationStyle()Returns the formatting style: True means Pure scientific formatting, False means standard.intgetSigDigits()Returns the number of significant digitsjava.lang.ObjectparseObject(java.lang.String source, java.text.ParsePosition pos)Dummy implementation of inherited abstract method.voidsetMaxWidth(int mWidth)Sets the maximum allowable length of the formattted number mantissa before exponential notation is used.voidsetScientificNotationStyle(boolean sciNote)Sets the format style used.voidsetSigDigits(int SigDigit)Sets the number of significant digits for the formatted number
-
-
-
Constructor Detail
-
ScientificFormat
public ScientificFormat()
-
ScientificFormat
public ScientificFormat(int sigDigit, int maxWidth, boolean SciNote)Sets the significant digits, maximum allowable width and number formatting style (SciNote == true for Pure formatting).
-
-
Method Detail
-
format
public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)Implementation of inherited abstract method. Checks to see if object to be formatted is of type Number. If so casts the Number object to double and calls the format method. Returns the result.- Specified by:
formatin classjava.text.Format
-
parseObject
public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)Dummy implementation of inherited abstract method.- Specified by:
parseObjectin classjava.text.Format
-
getSigDigits
public int getSigDigits()
Returns the number of significant digits
-
getMaxWidth
public int getMaxWidth()
Returns the maximum allowable width of formatted number excluding any exponentials
-
getScientificNotationStyle
public boolean getScientificNotationStyle()
Returns the formatting style: True means Pure scientific formatting, False means standard.
-
setSigDigits
public void setSigDigits(int SigDigit)
Sets the number of significant digits for the formatted number
-
setMaxWidth
public void setMaxWidth(int mWidth)
Sets the maximum allowable length of the formattted number mantissa before exponential notation is used.
-
setScientificNotationStyle
public void setScientificNotationStyle(boolean sciNote)
Sets the format style used. There are two output styles: Pure and Standard scientific notation. Pure formatted numbers have precisely the number of digits specified by the significant digits (sigDig) parameter and always specify a Base 10 Exponential(E). Standard formated numbers have the number of digits specified by the significant digits (sigDig) parameter but will not have a Base 10 Exponential(E) if the number of digits in the mantissa <= maxWidth.
-
format
public java.lang.String format(double d)
Format the number using scientific notation
-
-
DMelt 3.0 © DataMelt by jWork.ORG