OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 if (negative) { | 223 if (negative) { |
224 if (number == 0) return -0.0; | 224 if (number == 0) return -0.0; |
225 number = -number; | 225 number = -number; |
226 } | 226 } |
227 return static_cast<double>(number); | 227 return static_cast<double>(number); |
228 } | 228 } |
229 | 229 |
230 ASSERT(number != 0); | 230 ASSERT(number != 0); |
231 // The double could be constructed faster from number (mantissa), exponent | 231 // The double could be constructed faster from number (mantissa), exponent |
232 // and sign. Assuming it's a rare case more simple code is used. | 232 // and sign. Assuming it's a rare case more simple code is used. |
233 return static_cast<double>(negative ? -number : number) * pow(2.0, exponent); | 233 return ldexp(static_cast<double>(negative ? -number : number), exponent); |
234 } | 234 } |
235 | 235 |
236 | 236 |
237 template <class Iterator, class EndMark> | 237 template <class Iterator, class EndMark> |
238 double InternalStringToInt(UnicodeCache* unicode_cache, | 238 double InternalStringToInt(UnicodeCache* unicode_cache, |
239 Iterator current, | 239 Iterator current, |
240 EndMark end, | 240 EndMark end, |
241 int radix) { | 241 int radix) { |
242 const bool allow_trailing_junk = true; | 242 const bool allow_trailing_junk = true; |
243 const double empty_string_val = JunkStringValue(); | 243 const double empty_string_val = JunkStringValue(); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 ASSERT(buffer_pos < kBufferSize); | 661 ASSERT(buffer_pos < kBufferSize); |
662 buffer[buffer_pos] = '\0'; | 662 buffer[buffer_pos] = '\0'; |
663 | 663 |
664 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 664 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
665 return negative ? -converted : converted; | 665 return negative ? -converted : converted; |
666 } | 666 } |
667 | 667 |
668 } } // namespace v8::internal | 668 } } // namespace v8::internal |
669 | 669 |
670 #endif // V8_CONVERSIONS_INL_H_ | 670 #endif // V8_CONVERSIONS_INL_H_ |
OLD | NEW |