diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 80c23db..797ea77 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -594,9 +594,9 @@ class numeric : public schema // multipleOf - if the remainder of the division is 0 -> OK bool violates_multiple_of(T x) const { - json::number_integer_t n = static_cast(x / multipleOf_.second); - double res = (x - n * multipleOf_.second); - return fabs(res) > std::numeric_limits::epsilon(); + double res = std::remainder(x, multipleOf_.second); + double eps = std::nextafter(x, 0) - x; + return std::fabs(res) > std::fabs(eps); } void validate(const json &instance, basic_error_handler &e) const override