LibSQL: Use absolute value when comparing against floating point epsilon

Otherwise, any value that is less than another value would be considered
about equal by mistake.
This commit is contained in:
Timothy Flynn 2022-02-10 17:56:17 -05:00 committed by Linus Groh
parent e649ff5d31
commit 8fab99e920
Notes: sideshowbarker 2024-07-17 18:53:29 +09:00

View file

@ -773,8 +773,11 @@ int FloatImpl::compare(Value const& other) const
if (!casted.has_value()) {
return 1;
}
auto diff = value() - casted.value();
return (diff < NumericLimits<double>::epsilon()) ? 0 : ((diff > 0) ? 1 : -1);
if (fabs(diff) < NumericLimits<double>::epsilon())
return 0;
return diff < 0 ? -1 : 1;
}
String BooleanImpl::to_string() const