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

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 18147)
+++ runtime/lib/double.cc (working copy)
@@ -79,12 +79,13 @@
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 Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val));
+ if (BigintOperations::FitsIntoSmi(big)) {
+ return BigintOperations::ToSmi(big);
+ } else if (BigintOperations::FitsIntoMint(big)) {
+ return Mint::New(BigintOperations::ToMint(big));
} else {
- return BigintOperations::NewFromDouble(val);
+ return big.raw();
}
}
« 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