From cb59a5a9a2c7a0e93a6f23278a0ca3dead195f11 Mon Sep 17 00:00:00 2001 From: miloyip Date: Sat, 11 Apr 2015 11:34:44 +0800 Subject: [PATCH] Correct the Value::operator==() for double. --- include/rapidjson/document.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 82a86ed..8cc968a 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -701,8 +701,9 @@ public: case kNumberType: if (IsDouble() || rhs.IsDouble()) { - float delta = GetDouble() - rhs.GetDouble(); // May convert one operand from integer to double. - return delta >= 0.0 && delta <= 0.0; // Prevent -Wfloat-equal + double a = GetDouble(); // May convert from integer to double. + double b = rhs.GetDouble(); // Ditto + return a >= b && a <= b; // Prevent -Wfloat-equal } else return data_.n.u64 == rhs.data_.n.u64;