uniffi-rs
uniffi-rs copied to clipboard
Support large integers on Desktop JS
64 bit ints bits are tricky to support on JS, because it stores all numbers as floats. According to MDN, "A Number only keeps about 17 decimal places of precision", while 64bit numbers go up to 20 decimals places.
One solution for this is the BigInt type, which should handle large integers fine. However, in order to support that we would need to update our scaffolding functions to handle both BigInt and Number.
Furthermore, it appears that the webidl conversion layer, is handling overflow by converting the number to 0:
Arithmetic.add(18446744073709551615, 1)returns0Arithmetic.sub(18446744073709551615, 1)throwsIntegerOverflow.
I don't think this is a required for the initial implementation, but we fix it eventually.
┆Issue is synchronized with this Jira Task ┆Issue Number: UNIFFI-154