The following operators can be used with BigInt values.
+, *, -, **, %.
Bitwise operators can be used with BigInt except >>>, which is zero-fill right shift.
The unary operator (+) is not supported.
let a = BigInt(Number.MAX_SAFE_INTEGER) console.log(a);//from w w w . j a v a 2 s .com a = a + 1n ; console.log(a); a = a + 2n ; console.log(a); a = a * 2n ; console.log(a); a = a - 10n; console.log(a); a = a % 10n console.log(a); a = 2n ** 54n console.log(a); a = bigN * -1n console.log(a); a = 2n / 54n console.log(a);
An operation with a fractional result will be truncated when used with a BigInt.
let a = 4n / 2n;/*from ww w .j a v a2 s . c om*/ console.log(a); a = 5n / 2n console.log(a);