diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index d1f1b6f..855543e 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -1649,7 +1649,6 @@ public: /*! \note If the value is 64-bit integer type, it may lose precision. Use \c IsLosslessFloat() to check whether the converison is lossless. */ float GetFloat() const { - RAPIDJSON_ASSERT(IsFloat()); return static_cast(GetDouble()); } diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 9d3609d..d6c7492 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -652,6 +652,10 @@ TEST(Value, Float) { z.SetFloat(12.34f); EXPECT_NEAR(12.34f, z.GetFloat(), 0.0f); + // Issue 573 + z.SetInt(0); + EXPECT_EQ(0.0f, z.GetFloat()); + z = 56.78f; EXPECT_NEAR(56.78f, z.GetFloat(), 0.0f);