maxSafeInteger constant
- @Since.new("3.15")
The largest integer that a double value can uniquely represent.
The value, 253 - 1 or 9007199254740991, is the largest
integer where int.toDouble does not represent more than one integer.
The next larger double, 9007199254740992.0, is also the value of the
double literal 9007199254740993.0 and the result of int.toDouble for
both 9007199254740992 and 9007199254740993 (253 and
253 + 1).
Those integers require more than 53 bits to represent precisely,
and double values only have 53 bits of precision, so there is only
one double value per two integers. At larger scales, the gap between
double values becomes even larger.
Any double in the range minSafeInteger..maxSafeInteger is guaranteed to not have lost precision if it was converted from an int, or parsed from a decimal numeral, like a JSON number, into a double value, or an int value if using JavaScript numbers.
Corresponds to
Number.MAX_SAFE_INTEGER
in JavaScript.
Implementation
@Since("3.15")
static const int maxSafeInteger = 0x1F_FFFF_FFFF_FFFF;