if (!fields->canUseFastFormat) {
return false;
}
- auto i32 = static_cast<int32_t>(input);
- if (i32 != input || i32 == INT32_MIN) {
+ if (std::isnan(input)
+ || std::trunc(input) != input
+ || input <= INT32_MIN
+ || input > INT32_MAX) {
return false;
}
- doFastFormatInt32(i32, std::signbit(input), output);
+ doFastFormatInt32(static_cast<int32_t>(input), std::signbit(input), output);
return true;
}
if (!fields->canUseFastFormat) {
return false;
}
- auto i32 = static_cast<int32_t>(input);
- if (i32 != input || i32 == INT32_MIN) {
+ if (input <= INT32_MIN || input > INT32_MAX) {
return false;
}
- doFastFormatInt32(i32, input < 0, output);
+ doFastFormatInt32(static_cast<int32_t>(input), input < 0, output);
return true;
}
icu::UInitOnce gDefaultPropertiesInitOnce = U_INITONCE_INITIALIZER;
void U_CALLCONV initDefaultProperties(UErrorCode&) {
- *reinterpret_cast<DecimalFormatProperties*>(kRawDefaultProperties) = {}; // set to the default instance
+ new(kRawDefaultProperties) DecimalFormatProperties(); // set to the default instance
}
}