mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +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
Notes:
sideshowbarker
2024-07-17 18:53:29 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/8fab99e920 Pull-request: https://github.com/SerenityOS/serenity/pull/12433 Reviewed-by: https://github.com/linusg ✅
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue