3 ms·
Can't replace Number with BigInt as BigInt is orders of magnitude slower on certain operations. Try to do bitwise operations with BigInt, you'll see what I mean
by ossobuco 2y ago
Can't replace Number with BigInt as BigInt is orders of magnitude slower on certain operations. Try to do bitwise operations with BigInt, you'll see what I mean.
- no_wizard 2y agoHence roadmapped. You can’t today, certainly, it also can’t represent floating point numbers or be used with the Math object as noted. But the idea is that it should have been proposed with a roadmap of what it would look like to have it eventually supplant Number
- senfiaj 2y agobigint cannot be replaced by regular number when working with arbitrarily large whole numbers. With regular numbers you will lose precision out of the range [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER]. If you try to implement such functionality via JS, it would be even much slower than the bigint native implementation. So, it's great to have such thing natively implemented.