diyfp.h (rapidjson-1.0.2) | : | diyfp.h (rapidjson-1.1.0) | ||
---|---|---|---|---|
skipping to change at line 27 | skipping to change at line 27 | |||
// integers." ACM Sigplan Notices 45.6 (2010): 233-243. | // integers." ACM Sigplan Notices 45.6 (2010): 233-243. | |||
#ifndef RAPIDJSON_DIYFP_H_ | #ifndef RAPIDJSON_DIYFP_H_ | |||
#define RAPIDJSON_DIYFP_H_ | #define RAPIDJSON_DIYFP_H_ | |||
#include "../rapidjson.h" | #include "../rapidjson.h" | |||
#if defined(_MSC_VER) && defined(_M_AMD64) | #if defined(_MSC_VER) && defined(_M_AMD64) | |||
#include <intrin.h> | #include <intrin.h> | |||
#pragma intrinsic(_BitScanReverse64) | #pragma intrinsic(_BitScanReverse64) | |||
#pragma intrinsic(_umul128) | ||||
#endif | #endif | |||
RAPIDJSON_NAMESPACE_BEGIN | RAPIDJSON_NAMESPACE_BEGIN | |||
namespace internal { | namespace internal { | |||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
RAPIDJSON_DIAG_PUSH | RAPIDJSON_DIAG_PUSH | |||
RAPIDJSON_DIAG_OFF(effc++) | RAPIDJSON_DIAG_OFF(effc++) | |||
#endif | #endif | |||
#ifdef __clang__ | ||||
RAPIDJSON_DIAG_PUSH | ||||
RAPIDJSON_DIAG_OFF(padded) | ||||
#endif | ||||
struct DiyFp { | struct DiyFp { | |||
DiyFp() {} | DiyFp() : f(), e() {} | |||
DiyFp(uint64_t fp, int exp) : f(fp), e(exp) {} | DiyFp(uint64_t fp, int exp) : f(fp), e(exp) {} | |||
explicit DiyFp(double d) { | explicit DiyFp(double d) { | |||
union { | union { | |||
double d; | double d; | |||
uint64_t u64; | uint64_t u64; | |||
} u = { d }; | } u = { d }; | |||
int biased_e = static_cast<int>((u.u64 & kDpExponentMask) >> kDpSignific andSize); | int biased_e = static_cast<int>((u.u64 & kDpExponentMask) >> kDpSignific andSize); | |||
skipping to change at line 235 | skipping to change at line 241 | |||
if (dk - k > 0.0) | if (dk - k > 0.0) | |||
k++; | k++; | |||
unsigned index = static_cast<unsigned>((k >> 3) + 1); | unsigned index = static_cast<unsigned>((k >> 3) + 1); | |||
*K = -(-348 + static_cast<int>(index << 3)); // decimal exponent no need lookup table | *K = -(-348 + static_cast<int>(index << 3)); // decimal exponent no need lookup table | |||
return GetCachedPowerByIndex(index); | return GetCachedPowerByIndex(index); | |||
} | } | |||
inline DiyFp GetCachedPower10(int exp, int *outExp) { | inline DiyFp GetCachedPower10(int exp, int *outExp) { | |||
unsigned index = (exp + 348) / 8; | unsigned index = (static_cast<unsigned>(exp) + 348u) / 8u; | |||
*outExp = -348 + index * 8; | *outExp = -348 + static_cast<int>(index) * 8; | |||
return GetCachedPowerByIndex(index); | return GetCachedPowerByIndex(index); | |||
} | } | |||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
RAPIDJSON_DIAG_POP | RAPIDJSON_DIAG_POP | |||
#endif | #endif | |||
#ifdef __clang__ | ||||
RAPIDJSON_DIAG_POP | ||||
RAPIDJSON_DIAG_OFF(padded) | ||||
#endif | ||||
} // namespace internal | } // namespace internal | |||
RAPIDJSON_NAMESPACE_END | RAPIDJSON_NAMESPACE_END | |||
#endif // RAPIDJSON_DIYFP_H_ | #endif // RAPIDJSON_DIYFP_H_ | |||
End of changes. 5 change blocks. | ||||
3 lines changed or deleted | 14 lines changed or added |