Class Float64Stringifier

java.lang.Object
org.webpki.util.Float64Stringifier

public final class Float64Stringifier extends Object
IEEE-754 double to string encoder.

An implementation of Ryu for serializing IEEE-754 double precision values as specified by ECMAScript as well as by CBOR diagnostic notation.

  • Constructor Details

    • Float64Stringifier

      public Float64Stringifier()
  • Method Details

    • encode

      public static String encode(double value, boolean ecmaOriginalMode)
      Formats a number according to ECMAScript.

      This code is emulating 7.1.12.1 of the EcmaScript V6 specification.

      Note: {-}0.0, NaN, and ±Infinity is out of scope for this method.
      Parameters:
      value - Value to be formatted
      ecmaOriginalMode - If true use EcmaScript notation. If false use EcmaScript notation but always output a decimal point and at least one fractional digit. The latter is compatible with CBOR diagnostic notation
      Returns:
      String representation