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

Side by Side Diff: src/conversions-inl.h

Issue 14362023: Replace math.h with cmath (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 7 years, 8 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 | « src/conversions.cc ('k') | src/dtoa.cc » ('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_INL_H_ 28 #ifndef V8_CONVERSIONS_INL_H_
29 #define V8_CONVERSIONS_INL_H_ 29 #define V8_CONVERSIONS_INL_H_
30 30
31 #include <limits.h> // Required for INT_MAX etc. 31 #include <limits.h> // Required for INT_MAX etc.
32 #include <math.h>
33 #include <float.h> // Required for DBL_MAX and on Win32 for finite() 32 #include <float.h> // Required for DBL_MAX and on Win32 for finite()
34 #include <stdarg.h> 33 #include <stdarg.h>
34 #include <cmath>
35 #include "globals.h" // Required for V8_INFINITY 35 #include "globals.h" // Required for V8_INFINITY
36 36
37 // ---------------------------------------------------------------------------- 37 // ----------------------------------------------------------------------------
38 // Extra POSIX/ANSI functions for Win32/MSVC. 38 // Extra POSIX/ANSI functions for Win32/MSVC.
39 39
40 #include "conversions.h" 40 #include "conversions.h"
41 #include "double.h" 41 #include "double.h"
42 #include "platform.h" 42 #include "platform.h"
43 #include "scanner.h" 43 #include "scanner.h"
44 #include "strtod.h" 44 #include "strtod.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Copy least significant 32 bits of mantissa. 79 // Copy least significant 32 bits of mantissa.
80 OS::MemCopy(&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 (std::isnan(x)) return 0;
90 if (!isfinite(x) || x == 0) return x; 90 if (!std::isfinite(x) || x == 0) return x;
91 return (x >= 0) ? floor(x) : ceil(x); 91 return (x >= 0) ? floor(x) : ceil(x);
92 } 92 }
93 93
94 94
95 int32_t DoubleToInt32(double x) { 95 int32_t DoubleToInt32(double x) {
96 int32_t i = FastD2I(x); 96 int32_t i = FastD2I(x);
97 if (FastI2D(i) == x) return i; 97 if (FastI2D(i) == x) return i;
98 Double d(x); 98 Double d(x);
99 int exponent = d.Exponent(); 99 int exponent = d.Exponent();
100 if (exponent < 0) { 100 if (exponent < 0) {
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW
« no previous file with comments | « src/conversions.cc ('k') | src/dtoa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698