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

Unified Diff: src/conversions.cc

Issue 3564011: During StringToDouble negative exponents may be less than -999 with a result ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 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 | test/cctest/test-conversions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/conversions.cc
===================================================================
--- src/conversions.cc (revision 5591)
+++ src/conversions.cc (working copy)
@@ -665,9 +665,15 @@
buffer[buffer_pos++] = '-';
exponent = -exponent;
}
- if (exponent > 999) exponent = 999; // Result will be Infinity or 0 or -0.
- const int exp_digits = 3;
+ // The minimal/maximal double is +/-1.7e-308. Given that
+ // the buffer contains at most 773 (kMaxSignificantDigits + 1) the
+ // minimal possible exponent is hence -(308 + 773)=-1081.
+ // Since leading zeros are removed the maximal exponent cannot exceed 308.
+ // If the following test triggers the result will be +/-infinity or +/-0.
+ if (exponent > 9999) exponent = 9999;
+
+ const int exp_digits = 4;
for (int i = 0; i < exp_digits; i++) {
buffer[buffer_pos + exp_digits - 1 - i] = '0' + exponent % 10;
exponent /= 10;
« no previous file with comments | « no previous file | test/cctest/test-conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698