diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-09-08 16:03:35 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-09-08 16:11:20 -0700 |
commit | 03c2f62020e231db8be078d33e836cbe7e015460 (patch) | |
tree | 976bbdb9a68710c6684e24106beff768132e6041 /deps/v8/src/conversions-inl.h | |
parent | 0a127d6a694f2928f91d2ed51ef85a65768fdad3 (diff) | |
download | node-03c2f62020e231db8be078d33e836cbe7e015460.tar.gz |
Upgrade V8 to 3.6.2
Diffstat (limited to 'deps/v8/src/conversions-inl.h')
-rw-r--r-- | deps/v8/src/conversions-inl.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/deps/v8/src/conversions-inl.h b/deps/v8/src/conversions-inl.h index b82863856..41cf0d54c 100644 --- a/deps/v8/src/conversions-inl.h +++ b/deps/v8/src/conversions-inl.h @@ -32,13 +32,16 @@ #include <math.h> #include <float.h> // Required for DBL_MAX and on Win32 for finite() #include <stdarg.h> +#include "globals.h" // Required for V8_INFINITY // ---------------------------------------------------------------------------- // Extra POSIX/ANSI functions for Win32/MSVC. #include "conversions.h" -#include "strtod.h" +#include "double.h" #include "platform.h" +#include "scanner.h" +#include "strtod.h" namespace v8 { namespace internal { @@ -87,12 +90,15 @@ static inline double DoubleToInteger(double x) { int32_t DoubleToInt32(double x) { int32_t i = FastD2I(x); if (FastI2D(i) == x) return i; - static const double two32 = 4294967296.0; - static const double two31 = 2147483648.0; - if (!isfinite(x) || x == 0) return 0; - if (x < 0 || x >= two32) x = modulo(x, two32); - x = (x >= 0) ? floor(x) : ceil(x) + two32; - return (int32_t) ((x >= two31) ? x - two32 : x); + Double d(x); + int exponent = d.Exponent(); + if (exponent < 0) { + if (exponent <= -Double::kSignificandSize) return 0; + return d.Sign() * static_cast<int32_t>(d.Significand() >> -exponent); + } else { + if (exponent > 31) return 0; + return d.Sign() * static_cast<int32_t>(d.Significand() << exponent); + } } |