OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 digit = static_cast<char>(*current) - 'A' + 10; | 309 digit = static_cast<char>(*current) - 'A' + 10; |
310 } else { | 310 } else { |
311 if (allow_trailing_junk || !AdvanceToNonspace(¤t, end)) { | 311 if (allow_trailing_junk || !AdvanceToNonspace(¤t, end)) { |
312 break; | 312 break; |
313 } else { | 313 } else { |
314 return JUNK_STRING_VALUE; | 314 return JUNK_STRING_VALUE; |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 number = number * radix + digit; | 318 number = number * radix + digit; |
319 int overflow = number >> 53; | 319 int overflow = static_cast<int>(number >> 53); |
320 if (overflow != 0) { | 320 if (overflow != 0) { |
321 // Overflow occurred. Need to determine which direction to round the | 321 // Overflow occurred. Need to determine which direction to round the |
322 // result. | 322 // result. |
323 int overflow_bits_count = 1; | 323 int overflow_bits_count = 1; |
324 while (overflow > 1) { | 324 while (overflow > 1) { |
325 overflow_bits_count++; | 325 overflow_bits_count++; |
326 overflow >>= 1; | 326 overflow >>= 1; |
327 } | 327 } |
328 | 328 |
329 int dropped_bits_mask = ((1 << overflow_bits_count) - 1); | 329 int dropped_bits_mask = ((1 << overflow_bits_count) - 1); |
330 int dropped_bits = number & dropped_bits_mask; | 330 int dropped_bits = static_cast<int>(number) & dropped_bits_mask; |
331 number >>= overflow_bits_count; | 331 number >>= overflow_bits_count; |
332 exponent = overflow_bits_count; | 332 exponent = overflow_bits_count; |
333 | 333 |
334 bool zero_tail = true; | 334 bool zero_tail = true; |
335 while (true) { | 335 while (true) { |
336 ++current; | 336 ++current; |
337 if (current == end || !isDigit(*current, radix)) break; | 337 if (current == end || !isDigit(*current, radix)) break; |
338 zero_tail = zero_tail && *current == '0'; | 338 zero_tail = zero_tail && *current == '0'; |
339 exponent += radix_log_2; | 339 exponent += radix_log_2; |
340 } | 340 } |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 // Allocate result and fill in the parts. | 1035 // Allocate result and fill in the parts. |
1036 StringBuilder builder(result_size + 1); | 1036 StringBuilder builder(result_size + 1); |
1037 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); | 1037 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); |
1038 if (decimal_pos > 0) builder.AddCharacter('.'); | 1038 if (decimal_pos > 0) builder.AddCharacter('.'); |
1039 builder.AddSubstring(decimal_buffer, decimal_pos); | 1039 builder.AddSubstring(decimal_buffer, decimal_pos); |
1040 return builder.Finalize(); | 1040 return builder.Finalize(); |
1041 } | 1041 } |
1042 | 1042 |
1043 | 1043 |
1044 } } // namespace v8::internal | 1044 } } // namespace v8::internal |
OLD | NEW |