Reading BigInt in Chrome, how to handle big numbers in JavaScript & CSS architecture
Numerous battles have been carried out by developers with JavaScript’s Math
. Today, I found some big news on the web, about BigInt landing in V8.
- Mathias Bynens — BigInt: arbitrary-precision integers in JavaScript
- Adding BigInts to V8
- Source Code — v8/src/objects/bigint.h
It’s not going to rid us of BigNumber.js just yet, but it’s probably going to serve as the starting point for implementing BigDecimal.
Currently, there are a dozen variants to handle big numbers in JavaScript without touching Math
, ranging from keeping the numbers as strings to keeping the integer part and the fraction as separate strings in an array and join them together at a later time to using third party libraries which more or less use the same strategies I mentioned before. Here are a couple of articles I picked up by simply googling “handle big numbers in javascript”.
- StackOverflow question: Extremely large numbers in javascript
- Article: Working with large integers in JavaScript
- Article: Large Number Addition in Javascript
- Article: Be careful with JS numbers!
- Article: Handle number overflow in JavaScript
To be honest, I actually just typed “handle big n…” and Google was already suggesting “handle big numbers in javascript”. I wonder why 🤔…
On the projects I’m working on, right now, we’re using bignumber.js but there are other libraries out there:
- big.js — bignumber.js’ younger sibling.
- javascript-bignum
- biginteger.js
To put it in perspective, along with other initiatives of this kind, BigInt proves that the whole JavaScript community (users, stakeholders, regulators) is doing its best to turn JavaScript into a real boy instead of being the Pinocchio of programming languages.
On a different token, in the past couple of days, I had to think a lot about CSS and I remembered about an interesting article I read a couple of years ago. If you’re looking for a way to better organise your styles, definitely check out ITCSS.
The article is riddled with useful links, and I’ve extracted a couple of them, which were the most relevant when I was trying to learn how ITCSS works.