crossbind
GitHub

Numbers and BigInt

int, double and bool arrive as numbers and booleans. A 64-bit integer arrives as a BigInt, so no digit goes missing.

A JavaScript number holds integers exactly only up to 2^53. That is why int64_t and the other 64-bit integer types cross as BigInt: fibonacci(90) keeps all nineteen digits, while turning it into a Number rounds the last ones off.

The other way round, a 64-bit parameter takes a BigInt, or a Number that is a safe integer.

In the default 32-bit WebAssembly build, long and size_t are 32 bits wide, so they cross as plain numbers.

Try it
Make fibonacci return double instead of int64_t, in both native.h and native.cpp, and run it again: the result now loses the same digits as the Number.
Open in playgroundRuns without a compile until the C++, Rust, packages or imports change.
Console
Press Run, or Ctrl+Enter, to run main.js.
Type to search every guide page and section.
↑↓ navigate↵ openesc close