Skip to main content

Numbers

@serverSerrverlesskiy

There are two 2️⃣ types of numbers in modern JavaScript:

number#

Ordinary numbers in JavaScript are stored in the 64-bit IEEE-754 format, also called double precision floating point numbers. These are the numbers we will use most often. Integers are not considered a separate type of numbers. In addition to floating point numbers, the numeric data type also includes three character values: Infinity, -Infinity, and NaN (non-number).

Numbers

bigInt#

Numbers make it possible to work with integers of arbitrary length. They are rarely needed and are used in cases where you need to work with values ​​outside the maximum safe integer value Number.

Any number, even a decimal fraction with a lot of decimal places, is never quoted.

You can use four types of numeric literals: decimal, binary, octal, and hexadecimal. Since the last three are used quite rarely, we will omit their detailed description πŸ–ŠοΈ, but the curious can get acquainted with them here.

caution

Be careful when using leading zeros! This means you don't need to put zero before the decimal number.

1234567890
42
0888 // 888 is treated as decimal
0777 // treated as non-strict octal (511 decimal)

Payment#

Now you are on a stripped-down version of the site, after subscribing to Patreon, you will get full access to the training course, as well as access to our server's private channels in Discord.

Download our mobile application or get tested in our JavaScript telegram bot, and also subscribe to our news.

Become a Patron!

Sumerian school

Links#

  1. MDN web docs
  2. Code for Teens: The Perfect Beginner's Guide to Programming, Volume 1: Javascript - Jeremy Moritz
  3. JavaScript.ru
  4. Integer arithmetic

Contributors ✨#

Thanks goes to these wonderful people (emoji key):


Dmitriy Vasilev

πŸ“–πŸ’΅

Resoner2005

πŸ› 🎨 πŸ–‹

Become a Patron!