DoubleFormatter

Turns a double into a set of digits and an exponent, the same code Jackson and OpenJDK use.

References:

  1. Giulietti, "The Schubfach way to render doubles"

  2. IEEE Computer Society, "IEEE Standard for Floating-Point Arithmetic"

  3. Bouvier and Zimmermann, "Division-Free Binary-to-Decimal Conversion"

Divisions are avoided throughout, which helps architectures where they are slow. Section 10 of reference 1 covers that.

Functions

Link copied to clipboard

Converts a double to a Decimal that can then be rendered in several ways. Unlike toString this always returns a Decimal, so it is only defined for finite numbers.

Link copied to clipboard

Converts a double to a String the way ECMAScript's Number::toString defines it. Handles every double, including the non-finite ones.