| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 if (isSpecial()) | 621 if (isSpecial()) |
| 622 return *this; | 622 return *this; |
| 623 | 623 |
| 624 if (exponent() >= 0) | 624 if (exponent() >= 0) |
| 625 return *this; | 625 return *this; |
| 626 | 626 |
| 627 uint64_t result = m_data.coefficient(); | 627 uint64_t result = m_data.coefficient(); |
| 628 const int numberOfDigits = countDigits(result); | 628 const int numberOfDigits = countDigits(result); |
| 629 const int numberOfDropDigits = -exponent(); | 629 const int numberOfDropDigits = -exponent(); |
| 630 if (numberOfDigits < numberOfDropDigits) | 630 if (numberOfDigits < numberOfDropDigits) |
| 631 return zero(Positive); | 631 return isPositive() ? Decimal(1) : zero(Positive); |
| 632 | 632 |
| 633 result = scaleDown(result, numberOfDropDigits - 1); | 633 result = scaleDown(result, numberOfDropDigits - 1); |
| 634 if (sign() == Positive && result % 10 > 0) | 634 if (sign() == Positive && result % 10 > 0) |
| 635 result += 10; | 635 result += 10; |
| 636 result /= 10; | 636 result /= 10; |
| 637 return Decimal(sign(), 0, result); | 637 return Decimal(sign(), 0, result); |
| 638 } | 638 } |
| 639 | 639 |
| 640 Decimal Decimal::compareTo(const Decimal& rhs) const | 640 Decimal Decimal::compareTo(const Decimal& rhs) const |
| 641 { | 641 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 663 if (isSpecial()) | 663 if (isSpecial()) |
| 664 return *this; | 664 return *this; |
| 665 | 665 |
| 666 if (exponent() >= 0) | 666 if (exponent() >= 0) |
| 667 return *this; | 667 return *this; |
| 668 | 668 |
| 669 uint64_t result = m_data.coefficient(); | 669 uint64_t result = m_data.coefficient(); |
| 670 const int numberOfDigits = countDigits(result); | 670 const int numberOfDigits = countDigits(result); |
| 671 const int numberOfDropDigits = -exponent(); | 671 const int numberOfDropDigits = -exponent(); |
| 672 if (numberOfDigits < numberOfDropDigits) | 672 if (numberOfDigits < numberOfDropDigits) |
| 673 return zero(Positive); | 673 return isPositive() ? zero(Positive) : Decimal(-1); |
| 674 | 674 |
| 675 result = scaleDown(result, numberOfDropDigits - 1); | 675 result = scaleDown(result, numberOfDropDigits - 1); |
| 676 if (isNegative() && result % 10 > 0) | 676 if (isNegative() && result % 10 > 0) |
| 677 result += 10; | 677 result += 10; |
| 678 result /= 10; | 678 result /= 10; |
| 679 return Decimal(sign(), 0, result); | 679 return Decimal(sign(), 0, result); |
| 680 } | 680 } |
| 681 | 681 |
| 682 Decimal Decimal::fromDouble(double doubleValue) | 682 Decimal Decimal::fromDouble(double doubleValue) |
| 683 { | 683 { |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 } | 1026 } |
| 1027 return builder.toString(); | 1027 return builder.toString(); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 Decimal Decimal::zero(Sign sign) | 1030 Decimal Decimal::zero(Sign sign) |
| 1031 { | 1031 { |
| 1032 return Decimal(EncodedData(sign, EncodedData::ClassZero)); | 1032 return Decimal(EncodedData(sign, EncodedData::ClassZero)); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 } // namespace WebCore | 1035 } // namespace WebCore |
| OLD | NEW |