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:
Tete17
2025-12-16 12:36:51 +01:00
committed by Jelle Raaijmakers
parent 8ddf97053a
commit 322ff629a1
Notes: github-actions[bot] 2025-12-18 22:28:07 +00:00
2 changed files with 7 additions and 8 deletions

View File

@@ -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.