OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |