| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const double k2Pow52 = 4503599627370496.0; | 70 const double k2Pow52 = 4503599627370496.0; |
| 71 bool negative = x < 0; | 71 bool negative = x < 0; |
| 72 if (negative) { | 72 if (negative) { |
| 73 x = -x; | 73 x = -x; |
| 74 } | 74 } |
| 75 if (x < k2Pow52) { | 75 if (x < k2Pow52) { |
| 76 x += k2Pow52; | 76 x += k2Pow52; |
| 77 uint32_t result; | 77 uint32_t result; |
| 78 Address mantissa_ptr = reinterpret_cast<Address>(&x); | 78 Address mantissa_ptr = reinterpret_cast<Address>(&x); |
| 79 // Copy least significant 32 bits of mantissa. | 79 // Copy least significant 32 bits of mantissa. |
| 80 memcpy(&result, mantissa_ptr, sizeof(result)); | 80 OS::MemCopy(&result, mantissa_ptr, sizeof(result)); |
| 81 return negative ? ~result + 1 : result; | 81 return negative ? ~result + 1 : result; |
| 82 } | 82 } |
| 83 // Large number (outside uint32 range), Infinity or NaN. | 83 // Large number (outside uint32 range), Infinity or NaN. |
| 84 return 0x80000000u; // Return integer indefinite. | 84 return 0x80000000u; // Return integer indefinite. |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 inline double DoubleToInteger(double x) { | 88 inline double DoubleToInteger(double x) { |
| 89 if (isnan(x)) return 0; | 89 if (isnan(x)) return 0; |
| 90 if (!isfinite(x) || x == 0) return x; | 90 if (!isfinite(x) || x == 0) return x; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 ASSERT(buffer_pos < kBufferSize); | 669 ASSERT(buffer_pos < kBufferSize); |
| 670 buffer[buffer_pos] = '\0'; | 670 buffer[buffer_pos] = '\0'; |
| 671 | 671 |
| 672 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 672 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
| 673 return (sign == NEGATIVE) ? -converted : converted; | 673 return (sign == NEGATIVE) ? -converted : converted; |
| 674 } | 674 } |
| 675 | 675 |
| 676 } } // namespace v8::internal | 676 } } // namespace v8::internal |
| 677 | 677 |
| 678 #endif // V8_CONVERSIONS_INL_H_ | 678 #endif // V8_CONVERSIONS_INL_H_ |
| OLD | NEW |