diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index 54852f6a576..cfc793ee09b 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) if (negative) number *= -1; - u32 int_part = floor(number); + u64 int_part = floor(number); double decimal_part = number - int_part; Vector backwards_characters; @@ -111,7 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) for (u8 i = 0; i < precision; ++i) { decimal_part *= radix; - u32 integral = floor(decimal_part); + u64 integral = floor(decimal_part); characters.append(digits[integral]); decimal_part -= integral; } diff --git a/Userland/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js b/Userland/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js index 00541623950..eebb53d6cf9 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toString.js @@ -16,6 +16,7 @@ describe("correct behavior", () => { // Numbers above 2 ** 31 - 1 (Issue #3931) [2147483648, "2147483648"], // 2 ** 31 [4294967295, "4294967295"], // 2 ** 32 - 1 + [18014398509481984, "18014398509481984"], // 2 ** 54 ].forEach(testCase => { expect(testCase[0].toString()).toBe(testCase[1]); });