// Doubles are represented as Significant * 2 ^ Exponent. If the
// Exponent is not negative, the double value is already an integer.
if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d);
- return H_CONSTANT_DOUBLE(std::floor(d + 0.5));
+ return H_CONSTANT_DOUBLE(Floor(d + 0.5));
case kMathFround:
return H_CONSTANT_DOUBLE(static_cast<double>(static_cast<float>(d)));
case kMathFloor:
- return H_CONSTANT_DOUBLE(std::floor(d));
+ return H_CONSTANT_DOUBLE(Floor(d));
case kMathClz32: {
uint32_t i = DoubleToUint32(d);
return H_CONSTANT_INT(
#include "src/string-search.h"
#include "src/stub-cache.h"
#include "src/uri.h"
+#include "src/utils.h"
#include "src/v8threads.h"
#include "src/vm-state-inl.h"
isolate->counters()->math_floor()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return *isolate->factory()->NewNumber(std::floor(x));
+ return *isolate->factory()->NewNumber(Floor(x));
}
if (sign && value >= -0.5) return isolate->heap()->minus_zero_value();
// Do not call NumberFromDouble() to avoid extra checks.
- return *isolate->factory()->NewNumber(std::floor(value + 0.5));
+ return *isolate->factory()->NewNumber(Floor(value + 0.5));
}
double millis;
if (FLAG_verify_predictable) {
millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000
- millis += std::floor(isolate->heap()->synthetic_time());
+ millis += Floor(isolate->heap()->synthetic_time());
} else {
- millis = std::floor(base::OS::TimeCurrentMillis());
+ millis = Floor(base::OS::TimeCurrentMillis());
}
return *isolate->factory()->NewNumber(millis);
}
#include <limits.h>
#include <stdlib.h>
#include <string.h>
+#include <cmath>
#include "include/v8.h"
#include "src/allocation.h"
}
+// Floor(-0.0) == 0.0
+inline double Floor(double x) {
+#ifdef _MSC_VER
+ if (x == 0) return x; // Fix for issue 3477.
+#endif
+ return std::floor(x);
+}
+
+
// TODO(svenpanne) Clean up the whole power-of-2 mess.
inline int32_t WhichPowerOf2Abs(int32_t x) {
return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x));