mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:57:42 +00:00
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:
parent
e649ff5d31
commit
8fab99e920
1 changed files with 4 additions and 1 deletions
|
@ -773,8 +773,11 @@ int FloatImpl::compare(Value const& other) const
|
||||||
if (!casted.has_value()) {
|
if (!casted.has_value()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto diff = value() - casted.value();
|
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
|
String BooleanImpl::to_string() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue