Home >Web Front-end >Front-end Q&A >How many bits does a number occupy in JavaScript?
The memory occupied by numbers in JavaScript is 64 bits, which is 64 bits; numbers in JavaScript are stored as double-precision floating point numbers, and the memory occupied by double-precision floating point numbers is 8 bytes, which is 64 bits.
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Let’s talk about the number type first
“The JavaScript number type uses a 64-bit floating point number defined by the IEEE754 standard to represent a number”
Note: The memory space ratio of number does not distinguish between specific types (Java does). Integer types (byte, short, int, long) and floating point types (float, double)
If we only focus on numbers, the memory in the computer is 8Byte, that is, 8 bytes.
1byte (byte) = 8bit (bit)
8byte = 64 bits
Extended other data types
JavaScript basic data types occupy The memory is 8 bytes
Basic data types: string, number, undefined, boolean, null
Related recommendations: javascript learning tutorial
The above is the detailed content of How many bits does a number occupy in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!