mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-08 16:33:32 -05:00
Use normalize for load average values.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user