Safe comparison with 0

error: comparing floating point with == or != is unsafe [-Werror=float-equal]
This commit is contained in:
Irina 2021-09-28 15:44:38 +03:00 committed by GitHub
parent 3048707930
commit 07ae5af8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -800,7 +800,7 @@ class numeric : public schema
{
T value = instance; // conversion of json to value_type
if (multipleOf_.first && value != 0) // zero is multiple of everything
if (multipleOf_.first && ((value < 0) || (value > 0))) // zero is multiple of everything
if (violates_multiple_of(value))
e.error(ptr, instance, "instance is not a multiple of " + std::to_string(multipleOf_.second));