Skip to content

feat(js): add exact BigInt conversions, toI128LowBits and fromWords - #91

Open
nazarhussain wants to merge 4 commits into
mainfrom
nh/bigint-exact-variants
Open

nazarhussain wants to merge 4 commits into
mainfrom
nh/bigint-exact-variants

Conversation

@nazarhussain

Copy link
Copy Markdown
Contributor

Motivation

The fuzz harness in #41 needs exact BigInt conversions and word-level construction. These are the non-breaking parts of #83, so #41 can merge without waiting for the breaking change.

Description

Adds BigInt.toI64Exact/toU64Exact (throw Overflow instead of returning low bits), BigInt.toI128LowBits (BigInt.asIntN(128)) and BigInt.fromWords. It also fixes getValueBigintWords leaving sign_bit unset on overflow, and documents N-API Number conversion semantics. Existing methods are unchanged.

🤖 Generated with Claude Code

nazarhussain and others added 4 commits November 6, 2026 12:40
napi fills the low-order words and the sign even when the BigInt needs
more words than the buffer holds. Setting sign_bit before returning
error.Overflow lets callers catch the error and read the truncated value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BigInt.toI64Exact and BigInt.toU64Exact return error.Overflow when the
value does not fit, instead of the low 64 bits toI64/toU64 return.
BigInt.toI128LowBits returns BigInt.asIntN(128) semantics. Existing
methods are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant