Class RyuDouble

java.lang.Object
org.hipparchus.util.RyuDouble

public final class RyuDouble extends Object
An implementation of Ryū for double.

Ryū generates the shortest decimal representation of a floating point number that maintains round-trip safety. That is, a correct parser can recover the exact original number. Ryū is very fast (about 10 time faster than Double.toString()).

See Also:
  • Field Details

    • DEFAULT_LOW_EXP

      public static final int DEFAULT_LOW_EXP
      Default low switch level to scientific notation.
      See Also:
    • DEFAULT_HIGH_EXP

      public static final int DEFAULT_HIGH_EXP
      Default high switch level to scientific notation.
      See Also:
  • Method Details

    • doubleToString

      public static String doubleToString(double value)
      Convert a double to shortest string representation, preserving full accuracy.

      This implementation uses the same specifications as Double.toString(), i.e. it uses scientific notation if for numbers smaller than 10⁻³ or larger than 10⁺⁷, and decimal notion in between. That is it call doubleToString(value, -3, 7).

      Parameters:
      value - double number to convert
      Returns:
      shortest string representation
      See Also:
    • doubleToString

      public static String doubleToString(double value, int lowExp, int highExp)
      Convert a double to shortest string representation, preserving full accuracy.

      Number inside of the interval [10lowExp, 10highExp] are represented using decimal notation, numbers outside of this range are represented using scientific notation.

      Parameters:
      value - double number to convert
      lowExp - lowest decimal exponent for which decimal notation can be used
      highExp - highest decimal exponent for which decimal notation can be used
      Returns:
      shortest string representation
      See Also: