From: Shane Carr Date: Thu, 28 Sep 2017 20:24:35 +0000 (+0000) Subject: ICU-13177 Adding additional static casts to reduce compiler warnings. X-Git-Tag: release-60-rc~91 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87cd415960070fac7c8bfab0fb4e8c79d78b78bf;p=icu ICU-13177 Adding additional static casts to reduce compiler warnings. X-SVN-Rev: 40499 --- diff --git a/icu4c/source/i18n/number_decimalquantity.cpp b/icu4c/source/i18n/number_decimalquantity.cpp index 4162c9a0335..15e0bda090d 100644 --- a/icu4c/source/i18n/number_decimalquantity.cpp +++ b/icu4c/source/i18n/number_decimalquantity.cpp @@ -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(rReqPos) << 32); + fingerprint ^= (static_cast(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(toLong()); case PLURAL_OPERAND_F: - return toFractionLong(true); + return static_cast(toFractionLong(true)); case PLURAL_OPERAND_T: - return toFractionLong(false); + return static_cast(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(tempLong); int32_t _scale = scale + lostDigits; if (_scale >= 0) { // 1e22 is the largest exact double. diff --git a/icu4c/source/i18n/number_types.h b/icu4c/source/i18n/number_types.h index f84b6a93cad..d652c523de8 100644 --- a/icu4c/source/i18n/number_types.h +++ b/icu4c/source/i18n/number_types.h @@ -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(fValue == other.fValue); } void nullify() {