
Python vs JavaScript: Numbers
Are you a full-stack Python developer? Or maybe you know Python and want to learn some differences with JS? Sometimes things are easier to remember when put in comparison, so here is a simple cheatsheet of the implementation of numbers in both languages.
Python 3 and a “modern” JS engine are assumed (V8, SpiderMonkey, JavaScriptCore).
Integers
Standard integer (Python int
vs JS Number
)
Built-in integers with arbitrary precision (Python int
vs JS BigInt
)
Floats
Python float
vs JS Number
Infinity
Not-A-Number
Arithmetic operators
Formatting
Alternatives
JS
Build-in TypedArray
Nodejs C++ addons
Python
References:
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
• https://docs.python.org/3.1/library/stdtypes.html#typesnumeric
• https://docs.python.org/3/library/math.html
• https://docs.python.org/3/tutorial/floatingpoint.html
• https://en.wikipedia.org/wiki/Double-precision_floating-point_format