Make Json::normalize more strict
Rounding a regular FP value can give an invalid result - check the result too.
This commit is contained in:
parent
2bb07fe633
commit
f5095247e8
@ -211,11 +211,13 @@ rapidjson::Value xmrig::Json::normalize(double value, bool zero)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
if (!std::isnormal(value)) {
|
||||
const double value_rounded = floor(value * 100.0) / 100.0;
|
||||
|
||||
if (!std::isnormal(value) || !std::isnormal(value_rounded)) {
|
||||
return zero ? Value(0.0) : Value(kNullType);
|
||||
}
|
||||
|
||||
return Value(floor(value * 100.0) / 100.0);
|
||||
return Value(value_rounded);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user