]> granicus.if.org Git - icu/commitdiff
ICU-21896 Use double base in pow()
authorMojca Miklavec <mojca.miklavec.lists@gmail.com>
Mon, 17 Jan 2022 23:13:27 +0000 (00:13 +0100)
committerElango <elango@unicode.org>
Wed, 26 Jan 2022 19:26:11 +0000 (11:26 -0800)
gcc 5.5 on Solaris refuses to recognise pow(int, int32_t)

icu4c/source/i18n/plurrule.cpp

index cb817042da83d4a4db09a5b8586c2b17b8b5f5e8..7d1037f8bdd9e06968c8933b003606ba2eee6d9c 100644 (file)
@@ -1618,7 +1618,7 @@ FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f, int32_t e) {
     init(n, v, f, e);
     // check values. TODO make into unit test.
     //            
-    //            long visiblePower = (int) Math.pow(10, v);
+    //            long visiblePower = (int) Math.pow(10.0, v);
     //            if (decimalDigits > visiblePower) {
     //                throw new IllegalArgumentException();
     //            }
@@ -1871,7 +1871,7 @@ void FixedDecimal::adjustForMinFractionDigits(int32_t minFractionDigits) {
 
 double FixedDecimal::getPluralOperand(PluralOperand operand) const {
     switch(operand) {
-        case PLURAL_OPERAND_N: return (exponent == 0 ? source : source * pow(10, exponent));
+        case PLURAL_OPERAND_N: return (exponent == 0 ? source : source * pow(10.0, exponent));
         case PLURAL_OPERAND_I: return (double) longValue();
         case PLURAL_OPERAND_F: return static_cast<double>(decimalDigits);
         case PLURAL_OPERAND_T: return static_cast<double>(decimalDigitsWithoutTrailingZeros);
@@ -1922,14 +1922,14 @@ UnicodeString FixedDecimal::toString() const {
 }
 
 double FixedDecimal::doubleValue() const {
-    return (isNegative ? -source : source) * pow(10, exponent);
+    return (isNegative ? -source : source) * pow(10.0, exponent);
 }
 
 int64_t FixedDecimal::longValue() const {
     if (exponent == 0) {
         return intValue;
     } else {
-        return (long) (pow(10, exponent) * intValue);
+        return (long) (pow(10.0, exponent) * intValue);
     }
 }