Home>Article>Web Front-end> How many bytes are integers in JavaScript?

How many bytes are integers in JavaScript?

WBOY
WBOY Original
2022-02-07 16:26:09 4337browse

In JavaScript, integers have 8 bytes; the number memory space ratio does not distinguish between specific types. The basic variable type uses eight bytes of memory. Numbers and integers are stored in the form of 64-bit floating point numbers. , which is 8 bytes.

How many bytes are integers in JavaScript?

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

How many bytes are integers in JavaScript

Let’s talk about the number type first

“The JavaScript number type uses 64-bit floating point numbers defined by the IEEE754 standard to represent numbers”————Excerpted from Rhinoceros Book

The picture below is the explanation in mdn

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 largest share of the computer The memory is 8 bytes

Basic data types: string, number, undefined, boolean, null

Generally, Chinese occupies 2 bytes and English occupies 1 byte.

Related recommendations:javascript learning tutorial

The above is the detailed content of How many bytes are integers 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