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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "strtod.h" | 44 #include "strtod.h" |
45 | 45 |
46 namespace v8 { | 46 namespace v8 { |
47 namespace internal { | 47 namespace internal { |
48 | 48 |
49 inline double JunkStringValue() { | 49 inline double JunkStringValue() { |
50 return BitCast<double, uint64_t>(kQuietNaNMask); | 50 return BitCast<double, uint64_t>(kQuietNaNMask); |
51 } | 51 } |
52 | 52 |
53 | 53 |
| 54 inline double SignedZero(bool negative) { |
| 55 return negative ? uint64_to_double(Double::kSignMask) : 0.0; |
| 56 } |
| 57 |
| 58 |
54 // The fast double-to-unsigned-int conversion routine does not guarantee | 59 // The fast double-to-unsigned-int conversion routine does not guarantee |
55 // rounding towards zero, or any reasonable value if the argument is larger | 60 // rounding towards zero, or any reasonable value if the argument is larger |
56 // than what fits in an unsigned 32-bit integer. | 61 // than what fits in an unsigned 32-bit integer. |
57 inline unsigned int FastD2UI(double x) { | 62 inline unsigned int FastD2UI(double x) { |
58 // There is no unsigned version of lrint, so there is no fast path | 63 // There is no unsigned version of lrint, so there is no fast path |
59 // in this function as there is in FastD2I. Using lrint doesn't work | 64 // in this function as there is in FastD2I. Using lrint doesn't work |
60 // for values of 2^31 and above. | 65 // for values of 2^31 and above. |
61 | 66 |
62 // Convert "small enough" doubles to uint32_t by fixing the 32 | 67 // Convert "small enough" doubles to uint32_t by fixing the 32 |
63 // least significant non-fractional bits in the low 32 bits of the | 68 // least significant non-fractional bits in the low 32 bits of the |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 ASSERT(buffer_pos < kBufferSize); | 671 ASSERT(buffer_pos < kBufferSize); |
667 buffer[buffer_pos] = '\0'; | 672 buffer[buffer_pos] = '\0'; |
668 | 673 |
669 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 674 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
670 return (sign == NEGATIVE) ? -converted : converted; | 675 return (sign == NEGATIVE) ? -converted : converted; |
671 } | 676 } |
672 | 677 |
673 } } // namespace v8::internal | 678 } } // namespace v8::internal |
674 | 679 |
675 #endif // V8_CONVERSIONS_INL_H_ | 680 #endif // V8_CONVERSIONS_INL_H_ |
OLD | NEW |