WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
double-to-string.h
Go to the documentation of this file.
1// Copyright 2012 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_
29#define DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_
30
32
33namespace wpi::double_conversion {
34
36 public:
37 // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
38 // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
39 // function returns false.
40 static const int kMaxFixedDigitsBeforePoint = 60;
41 static const int kMaxFixedDigitsAfterPoint = 100;
42
43 // When calling ToExponential with a requested_digits
44 // parameter > kMaxExponentialDigits then the function returns false.
45 static const int kMaxExponentialDigits = 120;
46
47 // When calling ToPrecision with a requested_digits
48 // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits
49 // then the function returns false.
50 static const int kMinPrecisionDigits = 1;
51 static const int kMaxPrecisionDigits = 120;
52
53 // The maximal number of digits that are needed to emit a double in base 10.
54 // A higher precision can be achieved by using more digits, but the shortest
55 // accurate representation of any double will never use more digits than
56 // kBase10MaximalLength.
57 // Note that DoubleToAscii null-terminates its input. So the given buffer
58 // should be at least kBase10MaximalLength + 1 characters long.
59 static const int kBase10MaximalLength = 17;
60
61 // The maximal number of digits that are needed to emit a single in base 10.
62 // A higher precision can be achieved by using more digits, but the shortest
63 // accurate representation of any single will never use more digits than
64 // kBase10MaximalLengthSingle.
65 static const int kBase10MaximalLengthSingle = 9;
66
67 // The length of the longest string that 'ToShortest' can produce when the
68 // converter is instantiated with EcmaScript defaults (see
69 // 'EcmaScriptConverter')
70 // This value does not include the trailing '\0' character.
71 // This amount of characters is needed for negative values that hit the
72 // 'decimal_in_shortest_low' limit. For example: "-0.0000033333333333333333"
73 static const int kMaxCharsEcmaScriptShortest = 25;
74
85
86 // Flags should be a bit-or combination of the possible Flags-enum.
87 // - NO_FLAGS: no special flags.
88 // - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent
89 // form, emits a '+' for positive exponents. Example: 1.2e+2.
90 // - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is
91 // converted into decimal format then a trailing decimal point is appended.
92 // Example: 2345.0 is converted to "2345.".
93 // - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point
94 // emits a trailing '0'-character. This flag requires the
95 // EMIT_TRAILING_DECIMAL_POINT flag.
96 // Example: 2345.0 is converted to "2345.0".
97 // - UNIQUE_ZERO: "-0.0" is converted to "0.0".
98 // - NO_TRAILING_ZERO: Trailing zeros are removed from the fractional portion
99 // of the result in precision mode. Matches printf's %g.
100 // When EMIT_TRAILING_ZERO_AFTER_POINT is also given, one trailing zero is
101 // preserved.
102 // - EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL: when the input number has
103 // exactly one significant digit and is converted into exponent form then a
104 // trailing decimal point is appended to the significand in shortest mode
105 // or in precision mode with one requested digit.
106 // - EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL: in addition to a trailing
107 // decimal point emits a trailing '0'-character. This flag requires the
108 // EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL flag.
109 //
110 // Infinity symbol and nan_symbol provide the string representation for these
111 // special values. If the string is NULL and the special value is encountered
112 // then the conversion functions return false.
113 //
114 // The exponent_character is used in exponential representations. It is
115 // usually 'e' or 'E'.
116 //
117 // When converting to the shortest representation the converter will
118 // represent input numbers in decimal format if they are in the interval
119 // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[
120 // (lower boundary included, greater boundary excluded).
121 // Example: with decimal_in_shortest_low = -6 and
122 // decimal_in_shortest_high = 21:
123 // ToShortest(0.000001) -> "0.000001"
124 // ToShortest(0.0000001) -> "1e-7"
125 // ToShortest(111111111111111111111.0) -> "111111111111111110000"
126 // ToShortest(100000000000000000000.0) -> "100000000000000000000"
127 // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21"
128 //
129 // When converting to precision mode the converter may add
130 // max_leading_padding_zeroes before returning the number in exponential
131 // format.
132 // Example with max_leading_padding_zeroes_in_precision_mode = 6.
133 // ToPrecision(0.0000012345, 2) -> "0.0000012"
134 // ToPrecision(0.00000012345, 2) -> "1.2e-7"
135 // Similarly the converter may add up to
136 // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid
137 // returning an exponential representation. A zero added by the
138 // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit.
139 // Examples for max_trailing_padding_zeroes_in_precision_mode = 1:
140 // ToPrecision(230.0, 2) -> "230"
141 // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT.
142 // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
143 //
144 // When converting numbers with exactly one significant digit to exponent
145 // form in shortest mode or in precision mode with one requested digit, the
146 // EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT flags have
147 // no effect. Use the EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL flag to
148 // append a decimal point in this case and the
149 // EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL flag to also append a
150 // '0'-character in this case.
151 // Example with decimal_in_shortest_low = 0:
152 // ToShortest(0.0009) -> "9e-4"
153 // with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL deactivated.
154 // ToShortest(0.0009) -> "9.e-4"
155 // with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL activated.
156 // ToShortest(0.0009) -> "9.0e-4"
157 // with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL activated and
158 // EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL activated.
159 //
160 // The min_exponent_width is used for exponential representations.
161 // The converter adds leading '0's to the exponent until the exponent
162 // is at least min_exponent_width digits long.
163 // The min_exponent_width is clamped to 5.
164 // As such, the exponent may never have more than 5 digits in total.
166 const char* infinity_symbol,
167 const char* nan_symbol,
168 char exponent_character,
169 int decimal_in_shortest_low,
170 int decimal_in_shortest_high,
171 int max_leading_padding_zeroes_in_precision_mode,
172 int max_trailing_padding_zeroes_in_precision_mode,
173 int min_exponent_width = 0)
174 : flags_(flags),
175 infinity_symbol_(infinity_symbol),
176 nan_symbol_(nan_symbol),
177 exponent_character_(exponent_character),
178 decimal_in_shortest_low_(decimal_in_shortest_low),
179 decimal_in_shortest_high_(decimal_in_shortest_high),
180 max_leading_padding_zeroes_in_precision_mode_(
181 max_leading_padding_zeroes_in_precision_mode),
182 max_trailing_padding_zeroes_in_precision_mode_(
183 max_trailing_padding_zeroes_in_precision_mode),
184 min_exponent_width_(min_exponent_width) {
185 // When 'trailing zero after the point' is set, then 'trailing point'
186 // must be set too.
188 !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0));
189 }
190
191 // Returns a converter following the EcmaScript specification.
192 //
193 // Flags: UNIQUE_ZERO and EMIT_POSITIVE_EXPONENT_SIGN.
194 // Special values: "Infinity" and "NaN".
195 // Lower case 'e' for exponential values.
196 // decimal_in_shortest_low: -6
197 // decimal_in_shortest_high: 21
198 // max_leading_padding_zeroes_in_precision_mode: 6
199 // max_trailing_padding_zeroes_in_precision_mode: 0
201
202 // Computes the shortest string of digits that correctly represent the input
203 // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high
204 // (see constructor) it then either returns a decimal representation, or an
205 // exponential representation.
206 // Example with decimal_in_shortest_low = -6,
207 // decimal_in_shortest_high = 21,
208 // EMIT_POSITIVE_EXPONENT_SIGN activated, and
209 // EMIT_TRAILING_DECIMAL_POINT deactivated:
210 // ToShortest(0.000001) -> "0.000001"
211 // ToShortest(0.0000001) -> "1e-7"
212 // ToShortest(111111111111111111111.0) -> "111111111111111110000"
213 // ToShortest(100000000000000000000.0) -> "100000000000000000000"
214 // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21"
215 //
216 // Note: the conversion may round the output if the returned string
217 // is accurate enough to uniquely identify the input-number.
218 // For example the most precise representation of the double 9e59 equals
219 // "899999999999999918767229449717619953810131273674690656206848", but
220 // the converter will return the shorter (but still correct) "9e59".
221 //
222 // Returns true if the conversion succeeds. The conversion always succeeds
223 // except when the input value is special and no infinity_symbol or
224 // nan_symbol has been given to the constructor.
225 //
226 // The length of the longest result is the maximum of the length of the
227 // following string representations (each with possible examples):
228 // - NaN and negative infinity: "NaN", "-Infinity", "-inf".
229 // - -10^(decimal_in_shortest_high - 1):
230 // "-100000000000000000000", "-1000000000000000.0"
231 // - the longest string in range [0; -10^decimal_in_shortest_low]. Generally,
232 // this string is 3 + kBase10MaximalLength - decimal_in_shortest_low.
233 // (Sign, '0', decimal point, padding zeroes for decimal_in_shortest_low,
234 // and the significant digits).
235 // "-0.0000033333333333333333", "-0.0012345678901234567"
236 // - the longest exponential representation. (A negative number with
237 // kBase10MaximalLength significant digits).
238 // "-1.7976931348623157e+308", "-1.7976931348623157E308"
239 // In addition, the buffer must be able to hold the trailing '\0' character.
240 //
241 // Since the algorithm finds the shortest number of significant digits, it
242 // can produce an output that isn't the shortest possible if the
243 // decimal_in_shortest_high is high enough. For example, the number
244 // 1e23 could be written as 99999999999999991611392 with 23
245 // digits, however, it only needs one significant digit 1, and thus the
246 // result is 100000000000000000000000, which has 24 digits.
247 bool ToShortest(double value, StringBuilder* result_builder) const {
248 return ToShortestIeeeNumber(value, result_builder, SHORTEST);
249 }
250
251 // Same as ToShortest, but for single-precision floats.
252 //
253 // Since the algorithm finds the shortest number of significant digits, it
254 // can, in very rare cases, produce an output that isn't the shortest possible.
255 // For example, the number 1e11f could be written as 99999997952 with 11
256 // digits, however, it only needs one significant digit 1, and thus the
257 // result is 100000000000, which has 12 digits.
258 bool ToShortestSingle(float value, StringBuilder* result_builder) const {
259 return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE);
260 }
261
262
263 // Computes a decimal representation with a fixed number of digits after the
264 // decimal point. The last emitted digit is rounded.
265 //
266 // Examples:
267 // ToFixed(3.12, 1) -> "3.1"
268 // ToFixed(3.1415, 3) -> "3.142"
269 // ToFixed(1234.56789, 4) -> "1234.5679"
270 // ToFixed(1.23, 5) -> "1.23000"
271 // ToFixed(0.1, 4) -> "0.1000"
272 // ToFixed(1e30, 2) -> "1000000000000000019884624838656.00"
273 // ToFixed(0.1, 30) -> "0.100000000000000005551115123126"
274 // ToFixed(0.1, 17) -> "0.10000000000000001"
275 //
276 // If requested_digits equals 0, then the tail of the result depends on
277 // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT.
278 // Examples, for requested_digits == 0,
279 // let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be
280 // - false and false: then 123.45 -> 123
281 // 0.678 -> 1
282 // - true and false: then 123.45 -> 123.
283 // 0.678 -> 1.
284 // - true and true: then 123.45 -> 123.0
285 // 0.678 -> 1.0
286 //
287 // Returns true if the conversion succeeds. The conversion always succeeds
288 // except for the following cases:
289 // - the input value is special and no infinity_symbol or nan_symbol has
290 // been provided to the constructor,
291 // - 'value' > 10^kMaxFixedDigitsBeforePoint, or
292 // - 'requested_digits' > kMaxFixedDigitsAfterPoint.
293 // The last two conditions imply that the result for non-special values never
294 // contains more than
295 // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
296 // (one additional character for the sign, and one for the decimal point).
297 // In addition, the buffer must be able to hold the trailing '\0' character.
298 bool ToFixed(double value,
299 int requested_digits,
300 StringBuilder* result_builder) const;
301
302 // Computes a representation in exponential format with requested_digits
303 // after the decimal point. The last emitted digit is rounded.
304 // If requested_digits equals -1, then the shortest exponential representation
305 // is computed.
306 //
307 // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and
308 // exponent_character set to 'e'.
309 // ToExponential(3.12, 1) -> "3.1e0"
310 // ToExponential(5.0, 3) -> "5.000e0"
311 // ToExponential(0.001, 2) -> "1.00e-3"
312 // ToExponential(3.1415, -1) -> "3.1415e0"
313 // ToExponential(3.1415, 4) -> "3.1415e0"
314 // ToExponential(3.1415, 3) -> "3.142e0"
315 // ToExponential(123456789000000, 3) -> "1.235e14"
316 // ToExponential(1000000000000000019884624838656.0, -1) -> "1e30"
317 // ToExponential(1000000000000000019884624838656.0, 32) ->
318 // "1.00000000000000001988462483865600e30"
319 // ToExponential(1234, 0) -> "1e3"
320 //
321 // Returns true if the conversion succeeds. The conversion always succeeds
322 // except for the following cases:
323 // - the input value is special and no infinity_symbol or nan_symbol has
324 // been provided to the constructor,
325 // - 'requested_digits' > kMaxExponentialDigits.
326 //
327 // The last condition implies that the result never contains more than
328 // kMaxExponentialDigits + 8 characters (the sign, the digit before the
329 // decimal point, the decimal point, the exponent character, the
330 // exponent's sign, and at most 3 exponent digits).
331 // In addition, the buffer must be able to hold the trailing '\0' character.
332 bool ToExponential(double value,
333 int requested_digits,
334 StringBuilder* result_builder) const;
335
336
337 // Computes 'precision' leading digits of the given 'value' and returns them
338 // either in exponential or decimal format, depending on
339 // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the
340 // constructor).
341 // The last computed digit is rounded.
342 //
343 // Example with max_leading_padding_zeroes_in_precision_mode = 6.
344 // ToPrecision(0.0000012345, 2) -> "0.0000012"
345 // ToPrecision(0.00000012345, 2) -> "1.2e-7"
346 // Similarly the converter may add up to
347 // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid
348 // returning an exponential representation. A zero added by the
349 // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit.
350 // Examples for max_trailing_padding_zeroes_in_precision_mode = 1:
351 // ToPrecision(230.0, 2) -> "230"
352 // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT.
353 // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
354 // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no
355 // EMIT_TRAILING_ZERO_AFTER_POINT:
356 // ToPrecision(123450.0, 6) -> "123450"
357 // ToPrecision(123450.0, 5) -> "123450"
358 // ToPrecision(123450.0, 4) -> "123500"
359 // ToPrecision(123450.0, 3) -> "123000"
360 // ToPrecision(123450.0, 2) -> "1.2e5"
361 //
362 // Returns true if the conversion succeeds. The conversion always succeeds
363 // except for the following cases:
364 // - the input value is special and no infinity_symbol or nan_symbol has
365 // been provided to the constructor,
366 // - precision < kMinPericisionDigits
367 // - precision > kMaxPrecisionDigits
368 //
369 // The last condition implies that the result never contains more than
370 // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
371 // exponent character, the exponent's sign, and at most 3 exponent digits).
372 // In addition, the buffer must be able to hold the trailing '\0' character.
373 bool ToPrecision(double value,
374 int precision,
375 StringBuilder* result_builder) const;
376
377 enum DtoaMode {
378 // Produce the shortest correct representation.
379 // For example the output of 0.299999999999999988897 is (the less accurate
380 // but correct) 0.3.
382 // Same as SHORTEST, but for single-precision floats.
384 // Produce a fixed number of digits after the decimal point.
385 // For instance fixed(0.1, 4) becomes 0.1000
386 // If the input number is big, the output will be big.
388 // Fixed number of digits (independent of the decimal point).
390 };
391
392 // Converts the given double 'v' to digit characters. 'v' must not be NaN,
393 // +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also
394 // applies to 'v' after it has been casted to a single-precision float. That
395 // is, in this mode static_cast<float>(v) must not be NaN, +Infinity or
396 // -Infinity.
397 //
398 // The result should be interpreted as buffer * 10^(point-length).
399 //
400 // The digits are written to the buffer in the platform's charset, which is
401 // often UTF-8 (with ASCII-range digits) but may be another charset, such
402 // as EBCDIC.
403 //
404 // The output depends on the given mode:
405 // - SHORTEST: produce the least amount of digits for which the internal
406 // identity requirement is still satisfied. If the digits are printed
407 // (together with the correct exponent) then reading this number will give
408 // 'v' again. The buffer will choose the representation that is closest to
409 // 'v'. If there are two at the same distance, than the one farther away
410 // from 0 is chosen (halfway cases - ending with 5 - are rounded up).
411 // In this mode the 'requested_digits' parameter is ignored.
412 // - SHORTEST_SINGLE: same as SHORTEST but with single-precision.
413 // - FIXED: produces digits necessary to print a given number with
414 // 'requested_digits' digits after the decimal point. The produced digits
415 // might be too short in which case the caller has to fill the remainder
416 // with '0's.
417 // Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2.
418 // Halfway cases are rounded towards +/-Infinity (away from 0). The call
419 // toFixed(0.15, 2) thus returns buffer="2", point=0.
420 // The returned buffer may contain digits that would be truncated from the
421 // shortest representation of the input.
422 // - PRECISION: produces 'requested_digits' where the first digit is not '0'.
423 // Even though the length of produced digits usually equals
424 // 'requested_digits', the function is allowed to return fewer digits, in
425 // which case the caller has to fill the missing digits with '0's.
426 // Halfway cases are again rounded away from 0.
427 // DoubleToAscii expects the given buffer to be big enough to hold all
428 // digits and a terminating null-character. In SHORTEST-mode it expects a
429 // buffer of at least kBase10MaximalLength + 1. In all other modes the
430 // requested_digits parameter and the padding-zeroes limit the size of the
431 // output. Don't forget the decimal point, the exponent character and the
432 // terminating null-character when computing the maximal output size.
433 // The given length is only used in debug mode to ensure the buffer is big
434 // enough.
435 static void DoubleToAscii(double v,
436 DtoaMode mode,
437 int requested_digits,
438 char* buffer,
439 int buffer_length,
440 bool* sign,
441 int* length,
442 int* point);
443
444 private:
445 // Implementation for ToShortest and ToShortestSingle.
446 bool ToShortestIeeeNumber(double value,
447 StringBuilder* result_builder,
448 DtoaMode mode) const;
449
450 // If the value is a special value (NaN or Infinity) constructs the
451 // corresponding string using the configured infinity/nan-symbol.
452 // If either of them is NULL or the value is not special then the
453 // function returns false.
454 bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
455 // Constructs an exponential representation (i.e. 1.234e56).
456 // The given exponent assumes a decimal point after the first decimal digit.
457 void CreateExponentialRepresentation(const char* decimal_digits,
458 int length,
459 int exponent,
460 StringBuilder* result_builder) const;
461 // Creates a decimal representation (i.e 1234.5678).
462 void CreateDecimalRepresentation(const char* decimal_digits,
463 int length,
464 int decimal_point,
465 int digits_after_point,
466 StringBuilder* result_builder) const;
467
468 const int flags_;
469 const char* const infinity_symbol_;
470 const char* const nan_symbol_;
471 const char exponent_character_;
472 const int decimal_in_shortest_low_;
473 const int decimal_in_shortest_high_;
474 const int max_leading_padding_zeroes_in_precision_mode_;
475 const int max_trailing_padding_zeroes_in_precision_mode_;
476 const int min_exponent_width_;
477
479};
480
481} // namespace wpi::double_conversion
482
483#endif // DOUBLE_CONVERSION_DOUBLE_TO_STRING_H_
sign
Definition base.h:689
bool ToPrecision(double value, int precision, StringBuilder *result_builder) const
DtoaMode
Definition double-to-string.h:377
@ SHORTEST_SINGLE
Definition double-to-string.h:383
@ PRECISION
Definition double-to-string.h:389
@ FIXED
Definition double-to-string.h:387
@ SHORTEST
Definition double-to-string.h:381
static const int kMinPrecisionDigits
Definition double-to-string.h:50
static const int kMaxExponentialDigits
Definition double-to-string.h:45
bool ToExponential(double value, int requested_digits, StringBuilder *result_builder) const
static const int kBase10MaximalLengthSingle
Definition double-to-string.h:65
Flags
Definition double-to-string.h:75
@ NO_FLAGS
Definition double-to-string.h:76
@ NO_TRAILING_ZERO
Definition double-to-string.h:81
@ EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL
Definition double-to-string.h:82
@ EMIT_POSITIVE_EXPONENT_SIGN
Definition double-to-string.h:77
@ EMIT_TRAILING_DECIMAL_POINT
Definition double-to-string.h:78
@ EMIT_TRAILING_ZERO_AFTER_POINT
Definition double-to-string.h:79
@ UNIQUE_ZERO
Definition double-to-string.h:80
@ EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL
Definition double-to-string.h:83
static const int kBase10MaximalLength
Definition double-to-string.h:59
static void DoubleToAscii(double v, DtoaMode mode, int requested_digits, char *buffer, int buffer_length, bool *sign, int *length, int *point)
static const int kMaxPrecisionDigits
Definition double-to-string.h:51
static const int kMaxFixedDigitsAfterPoint
Definition double-to-string.h:41
bool ToFixed(double value, int requested_digits, StringBuilder *result_builder) const
DoubleToStringConverter(int flags, const char *infinity_symbol, const char *nan_symbol, char exponent_character, int decimal_in_shortest_low, int decimal_in_shortest_high, int max_leading_padding_zeroes_in_precision_mode, int max_trailing_padding_zeroes_in_precision_mode, int min_exponent_width=0)
Definition double-to-string.h:165
static const int kMaxCharsEcmaScriptShortest
Definition double-to-string.h:73
static const DoubleToStringConverter & EcmaScriptConverter()
bool ToShortestSingle(float value, StringBuilder *result_builder) const
Definition double-to-string.h:258
static const int kMaxFixedDigitsBeforePoint
Definition double-to-string.h:40
bool ToShortest(double value, StringBuilder *result_builder) const
Definition double-to-string.h:247
Definition diy-fp.h:33
#define DOUBLE_CONVERSION_ASSERT(condition)
Definition utils.h:46
#define DOUBLE_CONVERSION_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition utils.h:231