Floating point can't precisely represent all numbers. You'll ee this in integers as soon as your numbers are above 9,007,199,254,740,991
(Number.MAX_SAFE_INTEGER).
Beyond Number.MAX_SAFE_INTEGER + 1
(9007199254740992), the IEEE-754
floating-point format can no longer represent every consecutive integer because you no longer have a 1s bit; the lowest-order bit now represents multiples of 2
. Eventually, if we keep going, we lose that bit and only work in multiples of 4
. And so on.
Your values are well above that threshold, and so they get rounded to the nearest representable value.