| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index ceb6c106c9863dd7d58e6bf9331b70256db86c37..9d3be3361c6649fc21b68ceb7a6e752039d8dbbf 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -6597,9 +6597,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) {
|
| int exponent = number->get_exponent();
|
| int sign = number->get_sign();
|
|
|
| - // We compare with kSmiValueSize - 3 because (2^30 - 0.1) has exponent 29 and
|
| - // should be rounded to 2^30, which is not smi.
|
| - if (!sign && exponent <= kSmiValueSize - 3) {
|
| + if (exponent < -1) {
|
| + // Number in range ]-0.5..0.5[. These always round to +/-zero.
|
| + if (sign) return isolate->heap()->minus_zero_value();
|
| + return Smi::FromInt(0);
|
| + }
|
| +
|
| + // We compare with kSmiValueSize - 2 because (2^30 - 0.1) has exponent 29 and
|
| + // should be rounded to 2^30, which is not smi (for 31-bit smis, similar
|
| + // agument holds for 32-bit smis).
|
| + if (!sign && exponent < kSmiValueSize - 2) {
|
| return Smi::FromInt(static_cast<int>(value + 0.5));
|
| }
|
|
|
|
|