JavaScript Number Precision

The cluster focuses on JavaScript's use of 64-bit floating-point numbers for all numeric values, causing precision issues with large integers beyond 2^53, limitations in JSON handling, and the role of BigInt as a partial solution.

📉 Falling 0.4x Programming Languages
2,762
Comments
19
Years Active
5
Top Authors
#4924
Topic ID

Activity Over Time

2008
4
2009
9
2010
54
2011
66
2012
106
2013
144
2014
177
2015
124
2016
149
2017
162
2018
242
2019
220
2020
227
2021
278
2022
191
2023
208
2024
230
2025
166
2026
5

Keywords

bignumber.js US JIT SpiderMonkey JS BigInt mozilla.org crunch.js VM BigInts integers integer json javascript js numbers precision type floats floating

Sample Comments

pg314 Mar 22, 2017 View on HN

Even something as simple as integers is problematic, because they are underspecified. Since javascript uses 64 bit floating point numbers for all numeric types, 64 bit integers can not accurately be represented. If you need 64 bit integers, your best bet is to use strings...

kristianp Oct 16, 2010 View on HN

So basically, the only numeric type of javascript is a float, which can only represent integers up to 2^53 accurately. Not good if you need an int larger than that.

eqvinox Aug 11, 2025 View on HN

Why repeat JavaScript's mistake of having all numbers be floats, with no integer type? I thought that one's well known by now :(

TazeTSchnitzel Dec 18, 2014 View on HN

You're referring to the optimisation of storing JS Numbers as integers until they get too large, presumably?

hamandcheese Mar 20, 2018 View on HN

JavaScript uses 64 bit floats for all numbers. Unless you deal with particularly huge integers I don’t think there will be problems.“According to the ECMAScript standard, there is only one number type: the double-precision 64-bit binary format IEEE 754 value (numbers between -(253 -1) and 253 -1). There is no specific type for integers. In addition to being able to represent floating-point numbers, the number type has three symbolic values: +Infinity, -Infinity, and NaN (not-a-number).”<a

ohgodplsno Nov 16, 2021 View on HN

BigInt is relatively recent, all things considered. JS only having floats is a conception flaw.

dchest Jun 4, 2018 View on HN

Arbitrary precision integers is a JavaScript implementation detail; JSON standard doesn't specify number precision.

Illniyar May 23, 2019 View on HN

Because Numbers in javascripts are floats, and not allowing floats in numbers would be a serious backward compatibility issue.Also, I'm assuming there are performance issues with using bigints.

saagarjha Apr 29, 2021 View on HN

No, this is independent of BigInt. JITs speculate that numbers are integers for performance.

rmorey Apr 29, 2021 View on HN

Only if using the BigInt type: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...all other numbers are floats