1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:27:35 +00:00

LibJS: Implement the Number::remainder AO using fmod

The ECMA verbiage for modulus is the mathematical definition implemented
by fmod, so let's just use that rather than trying to reimplement all
the edge cases.
This commit is contained in:
Anonymous 2022-02-16 02:14:57 -08:00 committed by Linus Groh
parent 602190f66f
commit 1e0facb7ee
3 changed files with 9 additions and 30 deletions

View file

@ -53,6 +53,9 @@ class ExpectationError extends Error {
const valueToString = value => {
try {
if (value === 0 && 1 / value < 0) {
return "-0";
}
return String(value);
} catch {
// e.g for objects without a prototype, the above throws.