// Safe value
console.log(Number.isSafeInteger(Number.MAX_SAFE_INTEGER)) // true
// Unsafe value
console.log(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1)) // false
// Because it might have been rounded to it due to overflow
console.log(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 10)) // false
npm install big.js @types/big.js
import { Big } from 'big.js'
export const foo = new Big('111.11111111111111111111')
export const bar = foo.plus(new Big('0.00000000000000000001'))
// To get a number:
const x: number = Number(bar.toString()) // Loses the precision
console.log(Math.sqrt(-1)) // NaN
// Don't do this
console.log(NaN === NaN) // false!!
// Do this
console.log(Number.isNaN(NaN)) // true