Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: src/conversions.h

Issue 10825074: Actually fix build. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/conversions-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_CONVERSIONS_H_ 28 #ifndef V8_CONVERSIONS_H_
29 #define V8_CONVERSIONS_H_ 29 #define V8_CONVERSIONS_H_
30 30
31 #include "utils.h" 31 #include "utils.h"
32 #include "double.h"
33 32
34 namespace v8 { 33 namespace v8 {
35 namespace internal { 34 namespace internal {
36 35
37 class UnicodeCache; 36 class UnicodeCache;
38 37
39 // Maximum number of significant digits in decimal representation. 38 // Maximum number of significant digits in decimal representation.
40 // The longest possible double in decimal representation is 39 // The longest possible double in decimal representation is
41 // (2^53 - 1) * 2 ^ -1074 that is (2 ^ 53 - 1) * 5 ^ 1074 / 10 ^ 1074 40 // (2^53 - 1) * 2 ^ -1074 that is (2 ^ 53 - 1) * 5 ^ 1074 / 10 ^ 1074
42 // (768 digits). If we parse a number whose first digits are equal to a 41 // (768 digits). If we parse a number whose first digits are equal to a
43 // mean of 2 adjacent doubles (that could have up to 769 digits) the result 42 // mean of 2 adjacent doubles (that could have up to 769 digits) the result
44 // must be rounded to the bigger one unless the tail consists of zeros, so 43 // must be rounded to the bigger one unless the tail consists of zeros, so
45 // we don't need to preserve all the digits. 44 // we don't need to preserve all the digits.
46 const int kMaxSignificantDigits = 772; 45 const int kMaxSignificantDigits = 772;
47 46
48 47
49 inline bool isDigit(int x, int radix) { 48 inline bool isDigit(int x, int radix) {
50 return (x >= '0' && x <= '9' && x < '0' + radix) 49 return (x >= '0' && x <= '9' && x < '0' + radix)
51 || (radix > 10 && x >= 'a' && x < 'a' + radix - 10) 50 || (radix > 10 && x >= 'a' && x < 'a' + radix - 10)
52 || (radix > 10 && x >= 'A' && x < 'A' + radix - 10); 51 || (radix > 10 && x >= 'A' && x < 'A' + radix - 10);
53 } 52 }
54 53
55 54
56 inline double SignedZero(bool negative) {
57 return negative ? BitCast<double, uint64_t>(Double::kSignMask) : 0.0;
58 }
59
60
61 // The fast double-to-(unsigned-)int conversion routine does not guarantee 55 // The fast double-to-(unsigned-)int conversion routine does not guarantee
62 // rounding towards zero. 56 // rounding towards zero.
63 // For NaN and values outside the int range, return INT_MIN or INT_MAX. 57 // For NaN and values outside the int range, return INT_MIN or INT_MAX.
64 inline int FastD2IChecked(double x) { 58 inline int FastD2IChecked(double x) {
65 if (!(x >= INT_MIN)) return INT_MIN; // Negation to catch NaNs. 59 if (!(x >= INT_MIN)) return INT_MIN; // Negation to catch NaNs.
66 if (x > INT_MAX) return INT_MAX; 60 if (x > INT_MAX) return INT_MAX;
67 return static_cast<int>(x); 61 return static_cast<int>(x);
68 } 62 }
69 63
70 64
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Additional number to string conversions for the number type. 142 // Additional number to string conversions for the number type.
149 // The caller is responsible for calling free on the returned pointer. 143 // The caller is responsible for calling free on the returned pointer.
150 char* DoubleToFixedCString(double value, int f); 144 char* DoubleToFixedCString(double value, int f);
151 char* DoubleToExponentialCString(double value, int f); 145 char* DoubleToExponentialCString(double value, int f);
152 char* DoubleToPrecisionCString(double value, int f); 146 char* DoubleToPrecisionCString(double value, int f);
153 char* DoubleToRadixCString(double value, int radix); 147 char* DoubleToRadixCString(double value, int radix);
154 148
155 } } // namespace v8::internal 149 } } // namespace v8::internal
156 150
157 #endif // V8_CONVERSIONS_H_ 151 #endif // V8_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « no previous file | src/conversions-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698