Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 4 | |
| 5 | #ifndef V8_FIXED_DTOA_H_ |
| 6 | #define V8_FIXED_DTOA_H_ |
| 7 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 8 | #include "src/vector.h" |
| 9 | |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | |
| 13 | // Produces digits necessary to print a given number with |
| 14 | // 'fractional_count' digits after the decimal point. |
| 15 | // The buffer must be big enough to hold the result plus one terminating null |
| 16 | // character. |
| 17 | // |
| 18 | // The produced digits might be too short in which case the caller has to fill |
| 19 | // the gaps with '0's. |
| 20 | // Example: FastFixedDtoa(0.001, 5, ...) is allowed to return buffer = "1", and |
| 21 | // decimal_point = -2. |
| 22 | // Halfway cases are rounded towards +/-Infinity (away from 0). The call |
| 23 | // FastFixedDtoa(0.15, 2, ...) thus returns buffer = "2", decimal_point = 0. |
| 24 | // The returned buffer may contain digits that would be truncated from the |
| 25 | // shortest representation of the input. |
| 26 | // |
| 27 | // This method only works for some parameters. If it can't handle the input it |
| 28 | // returns false. The output is null-terminated when the function succeeds. |
| 29 | bool FastFixedDtoa(double v, int fractional_count, |
| 30 | Vector<char> buffer, int* length, int* decimal_point); |
| 31 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 32 | } // namespace internal |
| 33 | } // namespace v8 |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 34 | |
| 35 | #endif // V8_FIXED_DTOA_H_ |