Use normalize for load average values.

This commit is contained in:
XMRig 2019-12-04 10:25:26 +07:00
parent 901f1a7ab1
commit a4d35065d9
No known key found for this signature in database
GPG key ID: 446A53638BE94409
4 changed files with 26 additions and 11 deletions

View file

@ -28,6 +28,7 @@
#include <cassert>
#include <cmath>
namespace xmrig {
@ -154,6 +155,18 @@ unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsi
}
rapidjson::Value xmrig::Json::normalize(double value, bool zero)
{
using namespace rapidjson;
if (!std::isnormal(value)) {
return zero ? Value(0.0) : Value(kNullType);
}
return Value(floor(value * 100.0) / 100.0);
}
bool xmrig::JsonReader::isEmpty() const
{
return !m_obj.IsObject() || m_obj.ObjectEmpty();