Skip to main content
BigInt is a built-in Dart class representing an arbitrarily large integer. Unlike the standard int type, which is constrained to a 64-bit two’s complement representation (ranging from -2^63 to 2^63 - 1), BigInt can store integer values of any size, limited only by the available system memory.

Instantiation

Because Dart’s numeric literals are parsed as 64-bit integers by the compiler, instantiating a BigInt that exceeds the 64-bit limit requires parsing from a String. Using BigInt.from() with a numeric literal that exceeds the 64-bit limit results in a compile-time error.

Operators

BigInt overloads standard arithmetic, relational, and bitwise operators. This allows instances to be manipulated using the same syntax as native int types.
Note: The standard division operator (/) is fully supported between BigInt instances, but it evaluates to a double. To maintain arbitrary precision and return a BigInt, use the truncating division operator (~/).

Key Properties and Methods

BigInt provides several properties and methods for mathematical operations and state inspection.

Technical Characteristics

  • Immutability: Instances of BigInt are strictly immutable. All arithmetic and bitwise operations allocate and return a new BigInt instance in memory.
  • Performance Overhead: Because BigInt utilizes software-based arbitrary-precision arithmetic rather than hardware-level CPU instructions, operations are significantly slower and consume more memory than native int operations.
  • Web Compilation: When compiled to the web via dart2js or dartdevc (DDC), Dart’s BigInt uses a custom Dart implementation (a class backed by arrays of smaller integers) to guarantee consistent semantics with the Dart VM. It does not map to the native JavaScript BigInt type. Native JS BigInts are instead accessed via JS interop (e.g., JSBigInt).
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More