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

Side by Side Diff: Source/platform/Decimal.cpp

Issue 673583002: Remove wtf_ceil. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/Decimal.h ('k') | Source/platform/DecimalTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 alignedOperands.rhsCoefficient = rhsCoefficient; 610 alignedOperands.rhsCoefficient = rhsCoefficient;
611 return alignedOperands; 611 return alignedOperands;
612 } 612 }
613 613
614 static bool isMultiplePowersOfTen(uint64_t coefficient, int n) 614 static bool isMultiplePowersOfTen(uint64_t coefficient, int n)
615 { 615 {
616 return !coefficient || !(coefficient % scaleUp(1, n)); 616 return !coefficient || !(coefficient % scaleUp(1, n));
617 } 617 }
618 618
619 // Round toward positive infinity. 619 // Round toward positive infinity.
620 // Note: Mac ports defines ceil(x) as wtf_ceil(x), so we can't use name "ceil" h ere. 620 Decimal Decimal::ceil() const
621 Decimal Decimal::ceiling() const
622 { 621 {
623 if (isSpecial()) 622 if (isSpecial())
624 return *this; 623 return *this;
625 624
626 if (exponent() >= 0) 625 if (exponent() >= 0)
627 return *this; 626 return *this;
628 627
629 uint64_t result = m_data.coefficient(); 628 uint64_t result = m_data.coefficient();
630 const int numberOfDigits = countDigits(result); 629 const int numberOfDigits = countDigits(result);
631 const int numberOfDropDigits = -exponent(); 630 const int numberOfDropDigits = -exponent();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 } 887 }
889 888
890 Decimal Decimal::nan() 889 Decimal Decimal::nan()
891 { 890 {
892 return Decimal(EncodedData(Positive, EncodedData::ClassNaN)); 891 return Decimal(EncodedData(Positive, EncodedData::ClassNaN));
893 } 892 }
894 893
895 Decimal Decimal::remainder(const Decimal& rhs) const 894 Decimal Decimal::remainder(const Decimal& rhs) const
896 { 895 {
897 const Decimal quotient = *this / rhs; 896 const Decimal quotient = *this / rhs;
898 return quotient.isSpecial() ? quotient : *this - (quotient.isNegative() ? qu otient.ceiling() : quotient.floor()) * rhs; 897 return quotient.isSpecial() ? quotient : *this - (quotient.isNegative() ? qu otient.ceil() : quotient.floor()) * rhs;
899 } 898 }
900 899
901 Decimal Decimal::round() const 900 Decimal Decimal::round() const
902 { 901 {
903 if (isSpecial()) 902 if (isSpecial())
904 return *this; 903 return *this;
905 904
906 if (exponent() >= 0) 905 if (exponent() >= 0)
907 return *this; 906 return *this;
908 907
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 } 1016 }
1018 return builder.toString(); 1017 return builder.toString();
1019 } 1018 }
1020 1019
1021 Decimal Decimal::zero(Sign sign) 1020 Decimal Decimal::zero(Sign sign)
1022 { 1021 {
1023 return Decimal(EncodedData(sign, EncodedData::ClassZero)); 1022 return Decimal(EncodedData(sign, EncodedData::ClassZero));
1024 } 1023 }
1025 1024
1026 } // namespace blink 1025 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/Decimal.h ('k') | Source/platform/DecimalTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698