Home  >  Article  >  Web Front-end  >  How many bits does a number occupy in JavaScript?

How many bits does a number occupy in JavaScript?

WBOY
WBOYOriginal
2022-03-03 15:52:043963browse

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.

How many bits does a number occupy in JavaScript?

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

How many bits does a number occupy in JavaScript

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn