James Sinclair jrsinclair.com

Sick of the stupid jokes? Write your own arbitrary-precision JavaScript math library  ↦

JavaScript cops a lot of sneers and snide remarks. Some of them are deserved. Others, not so much. One that often comes up is floating point numbers. And in days past, it was a legitimate criticism.

It’s not that JavaScript did floating point numbers any worse than other languages. It uses the same IEEE standard that most of them do. The trouble is that floating point numbers were the only option. There was no other number type in JavaScript.

That’s no longer the case.

For over a year now, BigInt has officially been part of the TC39 ECMAScript standard. So we have another option for number types, besides floating point.

How does that help though?

Well, BigInt values are not restricted to 64 bits. They can be arbitrarily long. With a little mathematical care, we can use them to make very high precision calculations. And it’s not terribly hard either. You can write your own library from scratch with the power of BigInt.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00