Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JS Puzzles · Const

BigInt arithmetic

BigInt is JavaScript’s integer type for values of arbitrary length. Its arithmetic resembles Number arithmetic, but operands cannot be mixed with regular numbers and division truncates toward zero.

How it works

BigInt values represent integers of arbitrary length. Create them with an n suffix or BigInt(), then use matching BigInt operands for arithmetic; division rounds toward zero and produces another BigInt.

Syntax

BigInt(integerOrString)
integerLiteraln

Returns

Arithmetic expressions involving BigInts return BigInt values.

Key points

  • BigInt is intended for integer calculations whose values may exceed ordinary number precision.
  • An integer literal becomes BigInt by adding the n suffix.
  • The BigInt() function can construct a BigInt from supported string or number inputs.
  • Common arithmetic operators work with BigInt operands in much the same way as with ordinary numbers.
  • BigInt arithmetic preserves the BigInt result type.

Common mistakes

  • Arithmetic cannot combine BigInt and Number operands directly; convert one operand explicitly first.
  • Do not use unary plus as a BigInt conversion; use Number() when a number is required.

Example: BigInt arithmetic

const total = 2n + 3n;
const quotient = 5n / 2n;

console.log(total); // 5n
console.log(quotient); // 2n

BigInt operands support arithmetic, and division discards the fractional part by rounding toward zero.

When to use it

Large integer arithmetic

Calculating exact integer values beyond Number’s safe precision range.

Whole-number division

Performing integer division where fractional results are intentionally discarded.

Parsing large integers

Representing large integer quantities received as strings or other supported inputs.

Interview questions

QWhat is BigInt and how is it created?

BigInt is a numeric type for integers of arbitrary length. It can be created with an integer literal followed by n or with BigInt().

Follow-up: How does BigInt division differ from Number division? It rounds toward zero and removes the fractional part.

QCan BigInt and Number values be mixed in arithmetic?

Arithmetic operands must use the same numeric type, so a BigInt cannot be directly combined with a regular Number. Explicitly convert with BigInt() or Number() when mixing is required.

Follow-up: Why is explicit conversion preferred? It makes the intended result type clear and avoids implicit precision-related surprises.

QWhat does BigInt division return?

BigInt arithmetic returns BigInt values, including division. Division rounds toward zero, so 5n / 2n evaluates to 2n rather than a fractional value.

Follow-up: What happens when converting the result to Number()? The value becomes a Number, and large integers can lose precision.

  • BigInt()
  • Number()
  • division
  • unary plus operator
  • comparisons

Source: BigInt. Checked 2026-10-15.