mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Correct Clamp behaviour if the value lies in the halfway point
The C round differs from the web standard if the value lies exactly at the middle point. C rounds away from 0 while the web moves to the even value of the 2 extremes. This fixes at least 5 tests :)
This commit is contained in:
committed by
Jelle Raaijmakers
parent
8ddf97053a
commit
322ff629a1
Notes:
github-actions[bot]
2025-12-18 22:28:07 +00:00
Author: https://github.com/tete17 Commit: https://github.com/LadybirdBrowser/ladybird/commit/322ff629a19 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7157 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/gmta ✅
@@ -517,7 +517,7 @@ JS::ThrowCompletionOr<T> convert_to_int(JS::VM& vm, JS::Value value, EnforceRang
|
||||
|
||||
// 2. Round x to the nearest integer, choosing the even integer if it lies halfway between two, and choosing +0 rather than −0.
|
||||
// 3. Return x.
|
||||
return round(x);
|
||||
return AK::round_to<T>(x);
|
||||
}
|
||||
|
||||
// 8. If x is NaN, +0, +∞, or −∞, then return +0.
|
||||
|
||||
Reference in New Issue
Block a user