mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-03 21:06:30 +01:00
Another try with volatile
This commit is contained in:
parent
58d8d9ab9b
commit
98ddfacdf1
@ -791,8 +791,16 @@ public:
|
||||
// Checks whether a number can be losslessly converted to a double.
|
||||
bool IsLosslessDouble() const {
|
||||
if (!IsNumber()) return false;
|
||||
if (IsUint64()) return static_cast<volatile uint64_t>(static_cast<volatile double>(GetUint64())) == GetUint64();
|
||||
if (IsInt64()) return static_cast<volatile int64_t>(static_cast<volatile double>(GetInt64())) == GetInt64();
|
||||
if (IsUint64()) {
|
||||
uint64_t u = GetUint64();
|
||||
volatile double d = static_cast<double>(u);
|
||||
return static_cast<uint64_t>(d) == u;
|
||||
}
|
||||
if (IsInt64()) {
|
||||
int64_t i = GetInt64();
|
||||
volatile double d = static_cast<double>(i);
|
||||
return static_cast< int64_t>(d) == i;
|
||||
}
|
||||
return true; // double, int, uint are always lossless
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user