In JavaScript, how is "Nan" stored in memory?

Source: Internet
Author: User

I have been writing JavaScript For A Long Time and want to figure out what Nan is? Is it a type? Or a convention?

Run typeof Nan directly in the browser // return "Number"

It indicates that Nan is a number, not a new type.

Then there is a question about how Nan represents in the memory?

Google found: "When an infinite number is too large to be expressed, Nan indicates an illegal operation or an undefinable result.

Where, infinity can be expressed as INF. The value in the memory is, the order code is full 1, and the ending number is all 0. Nan indicates that the order code is full 1 and the ending number is incomplete. "

That is to say, Nan is stored in the memory with "full level code 1 and incomplete tail number 0.

Of course, in addition to "Nan", there are also JavaScript and how infinity is expressed.

You only need to enter 1/0 in the browser to know what is returned.

1/0 // return infinity

Typeof infinity // return "Number"

It seems that "Nan" and "infinity" are the same principle.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.