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 194 matching lines...) Loading... |
205 number++; // Rounding up. | 205 number++; // Rounding up. |
206 } else if (dropped_bits == middle_value) { | 206 } else if (dropped_bits == middle_value) { |
207 // Rounding to even to consistency with decimals: half-way case rounds | 207 // Rounding to even to consistency with decimals: half-way case rounds |
208 // up if significant part is odd and down otherwise. | 208 // up if significant part is odd and down otherwise. |
209 if ((number & 1) != 0 || !zero_tail) { | 209 if ((number & 1) != 0 || !zero_tail) { |
210 number++; // Rounding up. | 210 number++; // Rounding up. |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 // Rounding up may cause overflow. | 214 // Rounding up may cause overflow. |
215 if ((number & ((int64_t)1 << 53)) != 0) { | 215 if ((number & (static_cast<int64_t>(1) << 53)) != 0) { |
216 exponent++; | 216 exponent++; |
217 number >>= 1; | 217 number >>= 1; |
218 } | 218 } |
219 break; | 219 break; |
220 } | 220 } |
221 ++current; | 221 ++current; |
222 } while (current != end); | 222 } while (current != end); |
223 | 223 |
224 ASSERT(number < ((int64_t)1 << 53)); | 224 ASSERT(number < ((int64_t)1 << 53)); |
225 ASSERT(static_cast<int64_t>(static_cast<double>(number)) == number); | 225 ASSERT(static_cast<int64_t>(static_cast<double>(number)) == number); |
(...skipping 443 matching lines...) 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 |