Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

the maximum safe integer in JS is 2^53 - 1. [0]

if you can find a way to use only integers within that range, you can do it safely in plain JS.

for example, units of integer microdollars (one millionth of a dollar) allows you to deal in amounts up to $9 billion without exceeding the safe integer limit. if you want a larger range than that, you need to make a corresponding reduction in precision (such as using millidollars).

or, switch to a full-blown bignum / arbitrary precision library.

0: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: