Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:14:44+00:00 2026-05-25T01:14:44+00:00

Reading through the ECMAScript 5.1 specification , +0 and -0 are distinguished. Why then

  • 0

Reading through the ECMAScript 5.1 specification, +0 and -0 are distinguished.

Why then does +0 === -0 evaluate to true?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:14:45+00:00Added an answer on May 25, 2026 at 1:14 am

    JavaScript uses IEEE 754 standard to represent numbers. From Wikipedia:

    Signed zero is zero with an associated sign. In ordinary arithmetic, −0 = +0 = 0. However, in computing, some number representations allow for the existence of two zeros, often denoted by −0 (negative zero) and +0 (positive zero). This occurs in some signed number representations for integers, and in most floating point number representations. The number 0 is usually encoded as +0, but can be represented by either +0 or −0.

    The IEEE 754 standard for floating point arithmetic (presently used by most computers and programming languages that support floating point numbers) requires both +0 and −0. The zeroes can be considered as a variant of the extended real number line such that 1/−0 = −∞ and 1/+0 = +∞, division by zero is only undefined for ±0/±0 and ±∞/±∞.

    The article contains further information about the different representations.

    So this is the reason why, technically, both zeros have to be distinguished.

    However, +0 === -0 evaluates to true. Why is that (…) ?

    This behaviour is explicitly defined in section 11.9.6, the Strict Equality Comparison Algorithm (emphasis partly mine):

    The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:

    (…)

    • If Type(x) is Number, then

      1. If x is NaN, return false.
      2. If y is NaN, return false.
      3. If x is the same Number value as y, return true.
      4. If x is +0 and y is −0, return true.
      5. If x is −0 and y is +0, return true.
      6. Return false.

    (…)

    (The same holds for +0 == -0 btw.)

    It seems logically to treat +0 and -0 as equal. Otherwise we would have to take this into account in our code and I, personally, don’t want to do that 😉


    Note:

    ES2015 introduces a new comparison method, Object.is. Object.is explicitly distinguishes between -0 and +0:

    Object.is(-0, +0); // false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading through the Flickr API documentation it keeps stating I require an API key
Reading through this question on multi-threaded javascript, I was wondering if there would be
Reading through some of the questions here, the general concensus seems to be that
Reading through the SendAsync , BeginAsync method illustrations of Socket s, I realized that
Reading through documentation, I found following: 1.9.1 1.8.4 1.8.2 A version of 1.8.2 select
While reading through another question here, on creating a URL shortening service, it was
I'm reading through head first design patterns at the moment and while the book
I have been reading through the C++ FAQ and was curious about the friend
I've been reading through a lot of the rookie Java questions on finalize() and
I'm reading through the Zend Framework coding standards , where they state that curly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.