ICU-13246 Changing util64_pow to work on uint64_t to fix signed integer overflow warning in Clang

X-SVN-Rev: 40174
This commit is contained in:
Shane Carr 2017-06-17 00:48:17 +00:00
parent 229a0cb381
commit a5e7ffb0d9
2 changed files with 6 additions and 6 deletions

View file

@ -830,12 +830,12 @@ int64_t util64_fromDouble(double d) {
return result;
}
int64_t util64_pow(int32_t base, uint16_t exponent) {
uint64_t util64_pow(uint32_t base, uint16_t exponent) {
if (base == 0) {
return 0;
}
int64_t result = 1;
int64_t pow = base;
uint64_t result = 1;
uint64_t pow = base;
while (exponent > 0) {
if ((exponent & 1) == 1) {
result *= pow;
@ -1027,4 +1027,3 @@ U_NAMESPACE_END
/* U_HAVE_RBNF */
#endif

View file

@ -88,7 +88,9 @@ private:
int64_t util64_fromDouble(double d);
// raise radix to the power exponent, only non-negative exponents
int64_t util64_pow(int32_t radix, uint16_t exponent);
// Arithmetic is performed in unsigned space since overflow in
// signed space is undefined behavior.
uint64_t util64_pow(uint32_t radix, uint16_t exponent);
// convert n to digit string in buffer, return length of string
uint32_t util64_tou(int64_t n, UChar* buffer, uint32_t buflen, uint32_t radix = 10, UBool raw = FALSE);
@ -107,4 +109,3 @@ U_NAMESPACE_END
// NFRS_H
#endif