Class DoubleAnalyzer
DoubleAnalyzer (TeaVM 0.15.0, org.teavm.classlib.impl.text),
with its choice of digits replaced.
This is what Double.toString, String.valueOf(double), string concatenation and
StringBuilder.append(double) write digits from. The original multiplies by a 64-bit table
entry and drops low bits, so the 18-digit value it finds and the two edges of the interval of
decimals that read back as the same double are each a few units of the last digit low. A candidate
that close to an edge, or two candidates that close to a tie, are picked wrongly: it wrote text that
read back as a different double, or not the shortest. A subnormal it shifted up to a full
significand, which made the interval as narrow as a normal one's, so it wrote
4.940656458412465E-324 where a JVM writes 4.9E-324.
The table arithmetic stays as the fast path, with how far it can be off written down: below the
exact figure by less than four units, never above. The choice is made from it when it would be the
same for every figure within that; otherwise, and for every subnormal, Exact works the
digits out without error.
Found through Substitutions. It is a copy because a substitute replaces the class under
its own name and cannot call the original, and the tables are what the original is made of.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final long -
Method Summary
Modifier and TypeMethodDescriptionstatic voidanalyze(double d, DoubleAnalyzer.Result result) static intfastIntLog10(double d) static longmulAndShiftRight(long a, long b, int shift)
-
Field Details
-
DECIMAL_PRECISION
public static final int DECIMAL_PRECISION- See Also:
-
DOUBLE_MAX_POS
public static final long DOUBLE_MAX_POS- See Also:
-
-
Method Details
-
fastIntLog10
public static int fastIntLog10(double d) -
analyze
-
mulAndShiftRight
public static long mulAndShiftRight(long a, long b, int shift)
-