[#48] Tolerable difference depends on input values (and since x must be larger than multipleOf value in order to succeed, that's the critical one)

This commit is contained in:
garethsb-sony 2019-01-22 12:50:03 +00:00 committed by Patrick Boettcher
parent cf32c4e8fd
commit a1c6531540

View File

@ -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<json::number_integer_t>(x / multipleOf_.second);
double res = (x - n * multipleOf_.second);
return fabs(res) > std::numeric_limits<json::number_float_t>::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