| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ASSERT(buffer[(*length) -1] != '9'); | 256 ASSERT(buffer[(*length) -1] != '9'); |
| 257 buffer[(*length) - 1]++; | 257 buffer[(*length) - 1]++; |
| 258 return; | 258 return; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 | 263 |
| 264 // Let v = numerator / denominator < 10. | 264 // Let v = numerator / denominator < 10. |
| 265 // Then we generate 'count' digits of d = x.xxxxx... (without the decimal point) | 265 // Then we generate 'count' digits of d = x.xxxxx... (without the decimal point) |
| 266 // from left to right. Once 'count' digits have been produced we decide wether | 266 // from left to right. Once 'count' digits have been produced we decide whether |
| 267 // to round up or down. Remainders of exactly .5 round upwards. Numbers such | 267 // to round up or down. Remainders of exactly .5 round upwards. Numbers such |
| 268 // as 9.999999 propagate a carry all the way, and change the | 268 // as 9.999999 propagate a carry all the way, and change the |
| 269 // exponent (decimal_point), when rounding upwards. | 269 // exponent (decimal_point), when rounding upwards. |
| 270 static void GenerateCountedDigits(int count, int* decimal_point, | 270 static void GenerateCountedDigits(int count, int* decimal_point, |
| 271 Bignum* numerator, Bignum* denominator, | 271 Bignum* numerator, Bignum* denominator, |
| 272 Vector<char>(buffer), int* length) { | 272 Vector<char>(buffer), int* length) { |
| 273 ASSERT(count >= 0); | 273 ASSERT(count >= 0); |
| 274 for (int i = 0; i < count - 1; ++i) { | 274 for (int i = 0; i < count - 1; ++i) { |
| 275 uint16_t digit; | 275 uint16_t digit; |
| 276 digit = numerator->DivideModuloIntBignum(*denominator); | 276 digit = numerator->DivideModuloIntBignum(*denominator); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 delta_minus->Times10(); | 649 delta_minus->Times10(); |
| 650 delta_plus->AssignBignum(*delta_minus); | 650 delta_plus->AssignBignum(*delta_minus); |
| 651 } else { | 651 } else { |
| 652 delta_minus->Times10(); | 652 delta_minus->Times10(); |
| 653 delta_plus->Times10(); | 653 delta_plus->Times10(); |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 } } // namespace v8::internal | 658 } } // namespace v8::internal |
| OLD | NEW |