Package xal.tools.text
Class DoubleToString
java.lang.Object
xal.tools.text.DoubleToString
This algorithm for appending doubles to StringBuffer is borrowed from "Java
Performance Tuning" by Jack Shirazi. He explains how the JDK implementation
is "hideously under-optimized". This implementation is considerably more
efficient both in terms of speed and memory usage.
- Author:
- Craig McChesney
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
append
(StringBuffer s, double d) I think this is one of the two main methods in this class.static void
append
(StringBuffer s, int i) I think this is one of the two main methods in this class.static void
appendAsDouble
(StringBuffer s, long l, long lMag, int dMagnitude, int numFractDigits, char decimalPoint, char thousandsSeparator, int numDigitsSeparated, char negativePrefix, char negativeSuffix) One again, I'm not sure how to use this method, Craig was the original author.static void
appendFormatted
(StringBuffer s, double d, int numFractDigits, char decimalPoint, char thousandsSeparator, int numDigitsSeparated, char negativePrefix, char negativeSuffix) I'm not sure how this works or what it does since Craig originally build this class.static long
getNthDigit
(long l, int n) static void
static void
-
Field Details
-
INFINITY
public static final char[] INFINITYCharacter array representing number infinity -
NaN
public static final char[] NaNCharacter array representing Not-A-Number -
ZEROS
public static final char[][] ZEROSOrdered vectors of zeros
-
-
Constructor Details
-
DoubleToString
public DoubleToString()
-
-
Method Details
-
appendFormatted
public static void appendFormatted(StringBuffer s, double d, int numFractDigits, char decimalPoint, char thousandsSeparator, int numDigitsSeparated, char negativePrefix, char negativeSuffix) I'm not sure how this works or what it does since Craig originally build this class. There's not much documentation.- Parameters:
s
-d
-numFractDigits
-decimalPoint
-thousandsSeparator
-numDigitsSeparated
-negativePrefix
-negativeSuffix
-- Since:
- Apr 19, 2011
-
appendAsDouble
public static void appendAsDouble(StringBuffer s, long l, long lMag, int dMagnitude, int numFractDigits, char decimalPoint, char thousandsSeparator, int numDigitsSeparated, char negativePrefix, char negativeSuffix) One again, I'm not sure how to use this method, Craig was the original author.- Parameters:
s
-l
-lMag
-dMagnitude
-numFractDigits
-decimalPoint
-thousandsSeparator
-numDigitsSeparated
-negativePrefix
-negativeSuffix
-- Since:
- Apr 19, 2011
-
getNthDigit
public static long getNthDigit(long l, int n) -
main
-
main1
-
append
I think this is one of the two main methods in this class. It appends a double number to aStringBuffer
object using optimized float-to-character representation algorithms.- Parameters:
s
- string bufferd
- a double-valued number being appended to the string- Since:
- Apr 19, 2011
-
append
I think this is one of the two main methods in this class. It appends an integer number to aStringBuffer
object using optimized float-to-character representation algorithms.- Parameters:
s
- string bufferi
- a double-valued number being appended to the string- Since:
- Apr 19, 2011
-