comes up occasionally. This blog post explains what it means.
What are integers?
Second, the ECMAScript specification has integer operators: namely, all of the bitwise operators. Those operators convert their operands to 32-bit integers and return 32-bit integers. For the specification, integer only means that the numbers don’t have a decimal fraction, and 32-bit means that they are within a certain range. For engines, 32-bit integer means that an actual integer (non-floating-point) representation can usually be introduced or maintained.
Ranges of integers
- 53 bits plus a sign, range (−253, 253)
- Array indices :
- 32 bits, unsigned
- Maximum length: 232−1
- Range of indices: [0, 232−1) (excluding the maximum length!)
Bitwise operands :
- Unsigned right shift operator (>>>): 32 bits, unsigned, range [0, 232)
- All other bitwise operators: 32 bits, including a sign, range [−231, 231)
“Char codes”, UTF-16 code units as numbers:
- Accepted by String.fromCharCode()
- Returned by String.prototype.charCodeAt()
- 16 bit, unsigned
More blog posts on integers
All blog posts on integers have the label jsint
. Converting to integer is covered by two blog posts:
- Label bitwise_ops: blog posts on bitwise operators