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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // - a scaled (common) denominator. | 541 // - a scaled (common) denominator. |
542 // optionally (used by GenerateShortestDigits to decide if it has the shortest | 542 // optionally (used by GenerateShortestDigits to decide if it has the shortest |
543 // decimal converting back to v): | 543 // decimal converting back to v): |
544 // - v - m-: the distance to the lower boundary. | 544 // - v - m-: the distance to the lower boundary. |
545 // - m+ - v: the distance to the upper boundary. | 545 // - m+ - v: the distance to the upper boundary. |
546 // | 546 // |
547 // v, m+, m-, and therefore v - m- and m+ - v all share the same denominator. | 547 // v, m+, m-, and therefore v - m- and m+ - v all share the same denominator. |
548 // | 548 // |
549 // Let ep == estimated_power, then the returned values will satisfy: | 549 // Let ep == estimated_power, then the returned values will satisfy: |
550 // v / 10^ep = numerator / denominator. | 550 // v / 10^ep = numerator / denominator. |
551 // v's boundarys m- and m+: | 551 // v's boundaries m- and m+: |
552 // m- / 10^ep == v / 10^ep - delta_minus / denominator | 552 // m- / 10^ep == v / 10^ep - delta_minus / denominator |
553 // m+ / 10^ep == v / 10^ep + delta_plus / denominator | 553 // m+ / 10^ep == v / 10^ep + delta_plus / denominator |
554 // Or in other words: | 554 // Or in other words: |
555 // m- == v - delta_minus * 10^ep / denominator; | 555 // m- == v - delta_minus * 10^ep / denominator; |
556 // m+ == v + delta_plus * 10^ep / denominator; | 556 // m+ == v + delta_plus * 10^ep / denominator; |
557 // | 557 // |
558 // Since 10^(k-1) <= v < 10^k (with k == estimated_power) | 558 // Since 10^(k-1) <= v < 10^k (with k == estimated_power) |
559 // or 10^k <= v < 10^(k+1) | 559 // or 10^k <= v < 10^(k+1) |
560 // we then have 0.1 <= numerator/denominator < 1 | 560 // we then have 0.1 <= numerator/denominator < 1 |
561 // or 1 <= numerator/denominator < 10 | 561 // or 1 <= numerator/denominator < 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 delta_minus->Times10(); | 632 delta_minus->Times10(); |
633 delta_plus->AssignBignum(*delta_minus); | 633 delta_plus->AssignBignum(*delta_minus); |
634 } else { | 634 } else { |
635 delta_minus->Times10(); | 635 delta_minus->Times10(); |
636 delta_plus->Times10(); | 636 delta_plus->Times10(); |
637 } | 637 } |
638 } | 638 } |
639 } | 639 } |
640 | 640 |
641 } // namespace double_conversion | 641 } // namespace double_conversion |
OLD | NEW |