@Beta public final class DoubleFormatter extends Object
This is intended as a lower-cost replacement for the standard String.valueOf(double) since that method will cause lock contention if it's used too often.
Note that this implementation won't always produce the same results as java.lang.* formatting.
Also, this implementation is very poorly tested at the moment, so it should be used carefully, only in cases where you know the input will be well-defined and you don't need full precision.
Modifier and Type | Field and Description |
---|---|
private static char[] |
charForDigit |
private static double[] |
d_tenthPowers |
static char[] |
DOT_ZERO |
static char[] |
DOUBLE_ZERO |
static char[] |
DOUBLE_ZERO0 |
static char[] |
DOUBLE_ZERO2 |
private static int |
DoubleExpBias |
private static long |
DoubleExpMask |
private static int |
DoubleExpShift |
private static long |
DoubleFractMask |
private static long |
DoubleSignMask |
static char[] |
INFINITY |
(package private) static long[] |
l_tenthPowers |
static char[] |
NaN |
static char[] |
NEGATIVE_INFINITY |
static char[] |
POSITIVE_INFINITY |
static char[][] |
ZEROS |
Constructor and Description |
---|
DoubleFormatter() |
Modifier and Type | Method and Description |
---|---|
static void |
append(StringBuilder s,
double d) |
static void |
append(StringBuilder s,
int i) |
private static void |
appendFractDigits(StringBuilder s,
long i,
int decimalOffset) |
static StringBuilder |
fmt(StringBuilder target,
double v) |
static long |
getNthDigit(long l,
int n) |
private static int |
magnitude(double d) |
static String |
stringValue(double v) |
private static long |
tenthPower(long i)
Assumes i is positive.
|
private static void |
tooSmall(StringBuilder target,
long mantissa,
int exponent) |
public static final char[] INFINITY
public static final char[] NaN
public static final char[][] ZEROS
private static final char[] charForDigit
private static final long DoubleSignMask
private static final long DoubleExpMask
private static final long DoubleFractMask
private static final int DoubleExpShift
private static final int DoubleExpBias
private static final double[] d_tenthPowers
static long[] l_tenthPowers
public static final char[] NEGATIVE_INFINITY
public static final char[] POSITIVE_INFINITY
public static final char[] DOUBLE_ZERO
public static final char[] DOUBLE_ZERO2
public static final char[] DOUBLE_ZERO0
public static final char[] DOT_ZERO
private static void tooSmall(StringBuilder target, long mantissa, int exponent)
public static StringBuilder fmt(StringBuilder target, double v)
public static String stringValue(double v)
private static long tenthPower(long i)
private static int magnitude(double d)
public static long getNthDigit(long l, int n)
public static void append(StringBuilder s, double d)
public static void append(StringBuilder s, int i)
private static void appendFractDigits(StringBuilder s, long i, int decimalOffset)
Copyright © 2017. All rights reserved.