Class DoubleConversion

java.lang.Object
com.oracle.truffle.js.runtime.doubleconv.DoubleConversion

public final class DoubleConversion extends Object
This class provides the public API for the double conversion package. Using double-conversion version 3.3.0.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    bignumDtoa(double v, DtoaMode mode, int digits, DtoaBuffer buffer)
    Converts a double number to a string representation using the BignumDtoa algorithm and the specified conversion mode and number of digits.
    static boolean
    fastDtoaCounted(double v, int precision, DtoaBuffer buffer)
    Converts a double number to a string representation with the given number of digits using the FastDtoa algorithm.
    static boolean
    fastDtoaShortest(double v, DtoaBuffer buffer)
    Converts a double number to its shortest string representation using the FastDtoa algorithm.
    static boolean
    fixedDtoa(double v, int digits, DtoaBuffer buffer)
    Converts a double number to a string representation with a fixed number of digits after the decimal point using the FixedDtoa algorithm.
    static String
    toExponential(double value, int requestedDigits)
    Computes a representation in exponential format with requestedDigits after the decimal point.
    static String
    toExponential(double value, int requestedDigits, boolean uniqueZero)
    Computes a representation in exponential format with requestedDigits after the decimal point.
    static String
    toFixed(double value, int requestedDigits)
    Converts a double number to a string representation with a fixed number of digits after the decimal point.
    static String
    toPrecision(double value, int precision)
    Converts a double number to a string representation with a fixed number of digits.
    static String
    toShortest(double value)
    Converts a double number to its shortest string representation.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • toShortest

      public static String toShortest(double value)
      Converts a double number to its shortest string representation.
      Parameters:
      value - number to convert
      Returns:
      formatted number
    • toFixed

      public static String toFixed(double value, int requestedDigits)
      Converts a double number to a string representation with a fixed number of digits after the decimal point.
      Parameters:
      value - number to convert.
      requestedDigits - number of digits after decimal point
      Returns:
      formatted number
    • toPrecision

      public static String toPrecision(double value, int precision)
      Converts a double number to a string representation with a fixed number of digits.
      Parameters:
      value - number to convert
      precision - number of digits to create
      Returns:
      formatted number
    • bignumDtoa

      public static void bignumDtoa(double v, DtoaMode mode, int digits, DtoaBuffer buffer)
      Converts a double number to a string representation using the BignumDtoa algorithm and the specified conversion mode and number of digits.
      Parameters:
      v - number to convert
      mode - conversion mode
      digits - number of digits
      buffer - buffer to use
    • fastDtoaShortest

      public static boolean fastDtoaShortest(double v, DtoaBuffer buffer)
      Converts a double number to its shortest string representation using the FastDtoa algorithm.
      Parameters:
      v - number to convert
      buffer - buffer to use
      Returns:
      true if conversion succeeded
    • fastDtoaCounted

      public static boolean fastDtoaCounted(double v, int precision, DtoaBuffer buffer)
      Converts a double number to a string representation with the given number of digits using the FastDtoa algorithm.
      Parameters:
      v - number to convert
      precision - number of digits to generate
      buffer - buffer to use
      Returns:
      true if conversion succeeded
    • fixedDtoa

      public static boolean fixedDtoa(double v, int digits, DtoaBuffer buffer)
      Converts a double number to a string representation with a fixed number of digits after the decimal point using the FixedDtoa algorithm.
      Parameters:
      v - number to convert.
      digits - number of digits after the decimal point
      buffer - buffer to use
      Returns:
      true if conversion succeeded
    • toExponential

      public static String toExponential(double value, int requestedDigits)
      Computes a representation in exponential format with requestedDigits after the decimal point. The last emitted digit is rounded. If requestedDigits equals -1, then the shortest exponential representation is computed.
      Parameters:
      value - number to convert
      requestedDigits - number of digits after the decimal point
      Returns:
      true if conversion succeeded
    • toExponential

      public static String toExponential(double value, int requestedDigits, boolean uniqueZero)
      Computes a representation in exponential format with requestedDigits after the decimal point. The last emitted digit is rounded. If requestedDigits equals -1, then the shortest exponential representation is computed.
      Parameters:
      value - number to convert
      requestedDigits - number of digits after the decimal point
      uniqueZero - "-0.0" is converted to "0.0".
      Returns:
      true if conversion succeeded