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

Unified Diff: runtime/lib/double.cc

Issue 12180022: Fix Issue 8259: dart:math pow broken for large integers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/pow_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.cc
===================================================================
--- runtime/lib/double.cc (revision 18079)
+++ runtime/lib/double.cc (working copy)
@@ -79,12 +79,16 @@
args.SetAt(0, String::Handle(String::New(error_msg)));
Exceptions::ThrowByType(Exceptions::kUnsupported, args);
}
- if ((Smi::kMinValue <= val) && (val <= Smi::kMaxValue)) {
- return Smi::New(static_cast<intptr_t>(val));
- } else if ((Mint::kMinValue <= val) && (val <= Mint::kMaxValue)) {
- return Mint::New(static_cast<int64_t>(val));
+ const int64_t int64_val = static_cast<int64_t>(val);
+ // Check if overflow in double-to-int.
+ if ((int64_val == static_cast<int64_t>(0x8000000000000000LL)) &&
Vyacheslav Egorov (Google) 2013/02/05 00:34:36 I don't think we can do this. If a truncated doub
+ ((val < -2.0) || (val > 0.0))) {
+ return BigintOperations::NewFromDouble(val);
+ } else if ((Smi::kMinValue <= int64_val) && (int64_val <= Smi::kMaxValue)) {
+ return Smi::New(static_cast<intptr_t>(int64_val));
} else {
- return BigintOperations::NewFromDouble(val);
+ ASSERT((Mint::kMinValue <= int64_val) && (int64_val <= Mint::kMaxValue));
+ return Mint::New(int64_val);
}
}
« no previous file with comments | « no previous file | tests/standalone/pow_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698