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