Use normalize for load average values.
This commit is contained in:
parent
901f1a7ab1
commit
a4d35065d9
4 changed files with 26 additions and 11 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue