Chromium Code Reviews| Index: runtime/lib/double.cc |
| diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc |
| index 813002445b1cb00c566f19e418bc429e9691e81d..8a8c23797339cc81494141ebbd9f9fa029cc6768 100644 |
| --- a/runtime/lib/double.cc |
| +++ b/runtime/lib/double.cc |
| @@ -79,6 +79,19 @@ static RawInteger* DoubleToInteger(double val, const char* error_msg) { |
| args.SetAt(0, String::Handle(String::New(error_msg))); |
| Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
| } |
| + if (FLAG_truncate_ints_to_64_bits) { |
| + // TODO(alexmarkov): decide on the double-to-integer conversion semantics |
| + // in truncating mode. |
|
regis
2017/07/07 20:10:29
Something to discuss with the API people. You coul
alexmarkov
2017/07/07 20:46:38
Acknowledged.
|
| + int64_t ival = 0; |
| + if (val <= static_cast<double>(kMinInt64)) { |
| + ival = kMinInt64; |
| + } else if (val >= static_cast<double>(kMaxInt64)) { |
| + ival = kMaxInt64; |
| + } else { // representable in int64_t |
|
regis
2017/07/07 20:10:29
The convention is to use a capital letter and a pe
alexmarkov
2017/07/07 20:46:38
Done.
|
| + ival = static_cast<int64_t>(val); |
| + } |
| + return Integer::New(ival); |
| + } |
| if ((-1.0 < val) && (val < 1.0)) { |
| return Smi::New(0); |
| } |