Skip to content

bigIntIsSafeNumber

bigIntIsSafeNumber(value): boolean

Defined in: packages/core/src/big-int/is-safe-number.ts:22

Check whether converting a bigint to a number is exact.

True when the value lies within Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER inclusive, which is exactly the range where Number(value) round-trips. Outside it, Number(value) still succeeds and still returns a finite result — it just returns the wrong one — so a caller narrowing a bigint for presentation or arithmetic has to ask first.

bigint

The value to check.

boolean

True if Number(value) loses nothing.

bigIntIsSafeNumber(9007199254740991n); // true
bigIntIsSafeNumber(9007199254740992n); // false
```;