Package org.hipparchus.util
Class RyuDouble
java.lang.Object
org.hipparchus.util.RyuDouble
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 Summary
Modifier and TypeFieldDescriptionstatic final int
Default high switch level to scientific notation.static final int
Default low switch level to scientific notation. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
doubleToString
(double value) Convert a double to shortest string representation, preserving full accuracy.static String
doubleToString
(double value, int lowExp, int highExp) Convert a double to shortest string representation, preserving full accuracy.
-
Field Details
-
DEFAULT_LOW_EXP
public static final int DEFAULT_LOW_EXPDefault low switch level to scientific notation.- See Also:
-
DEFAULT_HIGH_EXP
public static final int DEFAULT_HIGH_EXPDefault high switch level to scientific notation.- See Also:
-
-
Method Details
-
doubleToString
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 calldoubleToString(value, -3, 7)
.- Parameters:
value
- double number to convert- Returns:
- shortest string representation
- See Also:
-
doubleToString
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 convertlowExp
- lowest decimal exponent for which decimal notation can be usedhighExp
- highest decimal exponent for which decimal notation can be used- Returns:
- shortest string representation
- See Also:
-