]> granicus.if.org Git - icu/commitdiff
ICU-13177 Adding additional static casts to reduce compiler warnings.
authorShane Carr <shane@unicode.org>
Thu, 28 Sep 2017 20:24:35 +0000 (20:24 +0000)
committerShane Carr <shane@unicode.org>
Thu, 28 Sep 2017 20:24:35 +0000 (20:24 +0000)
X-SVN-Rev: 40499

icu4c/source/i18n/number_decimalquantity.cpp
icu4c/source/i18n/number_types.h

index 4162c9a03359ea27ec9e524ea8b11fe6b4b0db91..15e0bda090d0cdf46c2526853bb34fea7e33f24e 100644 (file)
@@ -147,8 +147,8 @@ uint64_t DecimalQuantity::getPositionFingerprint() const {
     uint64_t fingerprint = 0;
     fingerprint ^= lOptPos;
     fingerprint ^= (lReqPos << 16);
-    fingerprint ^= ((long) rReqPos << 32);
-    fingerprint ^= ((long) rOptPos << 48);
+    fingerprint ^= (static_cast<uint64_t>(rReqPos) << 32);
+    fingerprint ^= (static_cast<uint64_t>(rOptPos) << 48);
     return fingerprint;
 }
 
@@ -207,11 +207,11 @@ double DecimalQuantity::getPluralOperand(PluralOperand operand) const {
 
     switch (operand) {
         case PLURAL_OPERAND_I:
-            return toLong();
+            return static_cast<double>(toLong());
         case PLURAL_OPERAND_F:
-            return toFractionLong(true);
+            return static_cast<double>(toFractionLong(true));
         case PLURAL_OPERAND_T:
-            return toFractionLong(false);
+            return static_cast<double>(toFractionLong(false));
         case PLURAL_OPERAND_V:
             return fractionCount();
         case PLURAL_OPERAND_W:
@@ -474,7 +474,7 @@ double DecimalQuantity::toDouble() const {
     for (int shift = precision - 1; shift >= lostDigits; shift--) {
         tempLong = tempLong * 10 + getDigitPos(shift);
     }
-    double result = tempLong;
+    double result = static_cast<double>(tempLong);
     int32_t _scale = scale + lostDigits;
     if (_scale >= 0) {
         // 1e22 is the largest exact double.
index f84b6a93cad93699a9d51effb5304a09f6da4adc..d652c523de80b7d1a53871dd7a3fa6c7478ddfee 100644 (file)
@@ -252,7 +252,8 @@ class NullableValue {
     }
 
     bool operator==(const NullableValue &other) const {
-        return fNull ? other.fNull : fValue == other.fValue;
+        // "fValue == other.fValue" returns UBool, not bool (causes compiler warnings)
+        return fNull ? other.fNull : static_cast<bool>(fValue == other.fValue);
     }
 
     void nullify() {