Class DoubleConversion
java.lang.Object
com.oracle.truffle.js.runtime.doubleconv.DoubleConversion
This class provides the public API for the double conversion package.
Using double-conversion version 3.3.0.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidbignumDtoa(double v, DtoaMode mode, int digits, DtoaBuffer buffer) Converts a double number to a string representation using theBignumDtoaalgorithm and the specified conversion mode and number of digits.static booleanfastDtoaCounted(double v, int precision, DtoaBuffer buffer) Converts a double number to a string representation with the given number of digits using theFastDtoaalgorithm.static booleanfastDtoaShortest(double v, DtoaBuffer buffer) Converts a double number to its shortest string representation using theFastDtoaalgorithm.static booleanfixedDtoa(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 theFixedDtoaalgorithm.static StringtoExponential(double value, int requestedDigits) Computes a representation in exponential format with requestedDigits after the decimal point.static StringtoExponential(double value, int requestedDigits, boolean uniqueZero) Computes a representation in exponential format with requestedDigits after the decimal point.static StringtoFixed(double value, int requestedDigits) Converts a double number to a string representation with a fixed number of digits after the decimal point.static StringtoPrecision(double value, int precision) Converts a double number to a string representation with a fixed number of digits.static StringtoShortest(double value) Converts a double number to its shortest string representation.
-
Method Details
-
toShortest
Converts a double number to its shortest string representation.- Parameters:
value- number to convert- Returns:
- formatted number
-
toFixed
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
Converts a double number to a string representation with a fixed number of digits.- Parameters:
value- number to convertprecision- number of digits to create- Returns:
- formatted number
-
bignumDtoa
Converts a double number to a string representation using theBignumDtoaalgorithm and the specified conversion mode and number of digits.- Parameters:
v- number to convertmode- conversion modedigits- number of digitsbuffer- buffer to use
-
fastDtoaShortest
Converts a double number to its shortest string representation using theFastDtoaalgorithm.- Parameters:
v- number to convertbuffer- buffer to use- Returns:
- true if conversion succeeded
-
fastDtoaCounted
Converts a double number to a string representation with the given number of digits using theFastDtoaalgorithm.- Parameters:
v- number to convertprecision- number of digits to generatebuffer- buffer to use- Returns:
- true if conversion succeeded
-
fixedDtoa
Converts a double number to a string representation with a fixed number of digits after the decimal point using theFixedDtoaalgorithm.- Parameters:
v- number to convert.digits- number of digits after the decimal pointbuffer- buffer to use- Returns:
- true if conversion succeeded
-
toExponential
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 convertrequestedDigits- number of digits after the decimal point- Returns:
- true if conversion succeeded
-
toExponential
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 convertrequestedDigits- number of digits after the decimal pointuniqueZero- "-0.0" is converted to "0.0".- Returns:
- true if conversion succeeded
-