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

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,13 +79,12 @@
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));
- } else {
- return BigintOperations::NewFromDouble(val);
+ const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val));
+ if (BigintOperations::FitsIntoSmi(big)) return BigintOperations::ToSmi(big);
Vyacheslav Egorov (Google) 2013/02/05 17:30:28 This code is hard to read. Can you make it if (.
srdjan 2013/02/05 18:04:08 Done.
+ if (BigintOperations::FitsIntoMint(big)) {
+ return Mint::New(BigintOperations::ToMint(big));
}
+ return big.raw();
}
DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) {
« 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