Skip to content

Commit b25043f

Browse files
committed
doc: clarify accepted number values for 64-bit FFI arguments
Signed-off-by: HoonDongKang <d159123@naver.com> Assisted-by: Codex:Astra-medium
1 parent aa7f3cd commit b25043f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎doc/api/ffi.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,16 @@ For 8-, 16-, and 32-bit integer types and for floating-point types, pass
540540
JavaScript `number` values that match the declared type.
541541

542542
For 64-bit integer types (`int64` and `uint64`), pass JavaScript `bigint`
543-
values.
543+
values within the declared type's range or safe integer `number` values.
544+
For `int64`, numbers must be between `Number.MIN_SAFE_INTEGER` and
545+
`Number.MAX_SAFE_INTEGER`, inclusive. For `uint64`, numbers must be between
546+
`0` and `Number.MAX_SAFE_INTEGER`, inclusive. This allows buffer lengths such
547+
as `buffer.byteLength` to be passed without an explicit `BigInt()` conversion.
548+
Use `bigint` for integers outside JavaScript's safe integer range.
549+
550+
Invalid arguments, including fractional numbers, `NaN`, infinities, and values
551+
outside these ranges, throw `ERR_INVALID_ARG_VALUE`. Return values for 64-bit
552+
integer types are always exposed as `bigint` values.
544553

545554
For pointer-like arguments:
546555

0 commit comments

Comments
 (0)