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

Side by Side Diff: runtime/third_party/double-conversion/src/strtod.cc

Issue 1239493002: error can shift more than 32 bits. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 ReadDiyFp(buffer, &input, &remaining_decimals); 279 ReadDiyFp(buffer, &input, &remaining_decimals);
280 // Since we may have dropped some digits the input is not accurate. 280 // Since we may have dropped some digits the input is not accurate.
281 // If remaining_decimals is different than 0 than the error is at most 281 // If remaining_decimals is different than 0 than the error is at most
282 // .5 ulp (unit in the last place). 282 // .5 ulp (unit in the last place).
283 // We don't want to deal with fractions and therefore keep a common 283 // We don't want to deal with fractions and therefore keep a common
284 // denominator. 284 // denominator.
285 const int kDenominatorLog = 3; 285 const int kDenominatorLog = 3;
286 const int kDenominator = 1 << kDenominatorLog; 286 const int kDenominator = 1 << kDenominatorLog;
287 // Move the remaining decimals into the exponent. 287 // Move the remaining decimals into the exponent.
288 exponent += remaining_decimals; 288 exponent += remaining_decimals;
289 int error = (remaining_decimals == 0 ? 0 : kDenominator / 2); 289 uint64_t error = (remaining_decimals == 0 ? 0 : kDenominator / 2);
290 290
291 int old_e = input.e(); 291 int old_e = input.e();
292 input.Normalize(); 292 input.Normalize();
293 error <<= old_e - input.e(); 293 error <<= old_e - input.e();
294 294
295 ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent); 295 ASSERT(exponent <= PowersOfTenCache::kMaxDecimalExponent);
296 if (exponent < PowersOfTenCache::kMinDecimalExponent) { 296 if (exponent < PowersOfTenCache::kMinDecimalExponent) {
297 *result = 0.0; 297 *result = 0.0;
298 return true; 298 return true;
299 } 299 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return next; 546 return next;
547 } else if ((Single(guess).Significand() & 1) == 0) { 547 } else if ((Single(guess).Significand() & 1) == 0) {
548 // Round towards even. 548 // Round towards even.
549 return guess; 549 return guess;
550 } else { 550 } else {
551 return next; 551 return next;
552 } 552 }
553 } 553 }
554 554
555 } // namespace double_conversion 555 } // namespace double_conversion
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698