BytesTrieBuilder::BTLinearMatchNode::BTLinearMatchNode(const char *bytes, int32_t len, Node *nextNode)
: LinearMatchNode(len, nextNode), s(bytes) {
- hash=hash*37+ustr_hashCharsN(bytes, len);
+ hash=static_cast<int32_t>(
+ static_cast<uint32_t>(hash)*37u + static_cast<uint32_t>(ustr_hashCharsN(bytes, len)));
}
UBool
* @see Object#hashCode()
*/
int32_t UnicodeSet::hashCode(void) const {
- int32_t result = len;
+ uint32_t result = static_cast<uint32_t>(len);
for (int32_t i = 0; i < len; ++i) {
- result *= 1000003;
+ result *= 1000003u;
result += list[i];
}
- return result;
+ return static_cast<int32_t>(result);
}
//----------------------------------------------------------------
UHashTok namekey, pathkey;
namekey.pointer = b->name;
pathkey.pointer = b->path;
- return uhash_hashChars(namekey)+37*uhash_hashChars(pathkey);
+ uint32_t unsignedHash = static_cast<uint32_t>(uhash_hashChars(namekey)) +
+ 37u * static_cast<uint32_t>(uhash_hashChars(pathkey));
+ return static_cast<int32_t>(unsignedHash);
}
/* compares two entries */
{
const UChar *limit;
int32_t count;
- int64_t result;
+ uint64_t result;
/* intialize parameters */
}
*len = count;
- return result;
+ return static_cast<int64_t>(result);
}
#define NIBBLE_PER_BYTE 2
#include "numrgts.h"
+#include <cmath> // std::signbit
#include <float.h> // DBL_MIN, DBL_MAX
#include <stdio.h>
{
UErrorCode status = U_ZERO_ERROR;
for(int32_t i=0; i < 2; ++i) {
- NumberFormat *f = (i == 0) ? NumberFormat::createInstance(status)
- : NumberFormat::createPercentInstance(status);
+ LocalPointer<NumberFormat> f(
+ ((i == 0) ? NumberFormat::createInstance(status) : NumberFormat::createPercentInstance(status)),
+ status);
if(U_FAILURE(status)) {
dataerrln("Couldn't create number format - %s", u_errorName(status));
return;
f->format(d, s);
Formattable n;
f->parse(s, n, status);
- if(U_FAILURE(status))
+ if(U_FAILURE(status)) {
errln("Couldn't parse!");
+ return;
+ }
double e = n.getDouble();
- logln(UnicodeString("") +
- d + " -> " +
- '"' + s + '"' + " -> " + e);
+ logln("%f -> \"%s\" -> %f", d, CStr(s)(), e);
#if (U_PLATFORM == U_PF_OS390 && !defined(IEEE_754)) || U_PLATFORM == U_PF_OS400
if (e != 0.0) {
#else
- if (e != 0.0 || 1.0/e > 0.0) {
+ if (e != 0.0 || (std::signbit(e) == false)) {
#endif
- logln("Failed to parse negative zero");
+ errln("Failed to parse negative zero");
}
- delete f;
}
}
static int64_t
uto64(const UChar *buffer)
{
- int64_t result = 0;
+ uint64_t result = 0;
/* iterate through buffer */
while(*buffer) {
/* read the next digit */
- result *= 16;
+ result *= 16u;
if (!u_isxdigit(*buffer)) {
log_err("\\u%04X is not a valid hex digit for this test\n", (UChar)*buffer);
}
result += *buffer - 0x0030 - (*buffer >= 0x0041 ? (*buffer >= 0x0061 ? 39 : 7) : 0);
buffer++;
}
- return result;
+ return (int64_t)result;
}
#endif