OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 double abs_value = value; | 204 double abs_value = value; |
205 if (value < 0) { | 205 if (value < 0) { |
206 abs_value = -value; | 206 abs_value = -value; |
207 negative = true; | 207 negative = true; |
208 } | 208 } |
209 | 209 |
210 // If abs_value has more than kMaxDigitsBeforePoint digits before the point | 210 // If abs_value has more than kMaxDigitsBeforePoint digits before the point |
211 // use the non-fixed conversion routine. | 211 // use the non-fixed conversion routine. |
212 if (abs_value >= kFirstNonFixed) { | 212 if (abs_value >= kFirstNonFixed) { |
213 char arr[100]; | 213 char arr[100]; |
214 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 214 Vector<char> buffer(arr, arraysize(arr)); |
215 return StrDup(DoubleToCString(value, buffer)); | 215 return StrDup(DoubleToCString(value, buffer)); |
216 } | 216 } |
217 | 217 |
218 // Find a sufficiently precise decimal representation of n. | 218 // Find a sufficiently precise decimal representation of n. |
219 int decimal_point; | 219 int decimal_point; |
220 int sign; | 220 int sign; |
221 // Add space for the '\0' byte. | 221 // Add space for the '\0' byte. |
222 const int kDecimalRepCapacity = | 222 const int kDecimalRepCapacity = |
223 kMaxDigitsBeforePoint + kMaxDigitsAfterPoint + 1; | 223 kMaxDigitsBeforePoint + kMaxDigitsAfterPoint + 1; |
224 char decimal_rep[kDecimalRepCapacity]; | 224 char decimal_rep[kDecimalRepCapacity]; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 return StringToDouble( | 494 return StringToDouble( |
495 unicode_cache, flat.ToOneByteVector(), flags, empty_string_val); | 495 unicode_cache, flat.ToOneByteVector(), flags, empty_string_val); |
496 } else { | 496 } else { |
497 return StringToDouble( | 497 return StringToDouble( |
498 unicode_cache, flat.ToUC16Vector(), flags, empty_string_val); | 498 unicode_cache, flat.ToUC16Vector(), flags, empty_string_val); |
499 } | 499 } |
500 } | 500 } |
501 | 501 |
502 | 502 |
503 } } // namespace v8::internal | 503 } } // namespace v8::internal |
OLD | NEW |