Given a BigInt in JS, how do you compute its modulo?
10n % 3 // Uncaught TypeError: can't convert BigInt to number
edit: the difference between this question and the one linked as similar is that this question only pertains to BigInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt which is fairly recent.
Both operands of an arithmetic operation involving a BigInt must be BigInts. In your case:
// BigInt literal
10n % 3n;
// BigInt explicit conversion
10n % BigInt(3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With