Skip to content

Handle zero limb when counting leading zeroes #1110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10617,6 +10617,8 @@ do { \
/* a != 0 */
static inline js_limb_t js_limb_clz(js_limb_t a)
{
if (!a)
return JS_LIMB_BITS;
return clz32(a);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/test_bigint.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function test_bigint1()

r = 1n << 32n;
assert(r, 4294967296n, "1 << 32n === 4294967296n");

assert(String(-9223372036854775808n), "-9223372036854775808");
}

function test_bigint2()
Expand Down