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

  • SEARCH
  • Home
  • 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 8885207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:15:07+00:00 2026-06-14T21:15:07+00:00

Why do doubles have -0 as well as +0 ? What is the background

  • 0

Why do doubles have -0 as well as +0? What is the background and significance?

  • 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-06-14T21:15:09+00:00Added an answer on June 14, 2026 at 9:15 pm

    -0 is (generally) treated as 0 *******. It can result when a negative floating-point number is so close to zero that it can be considered 0 (to be clear, I’m referring to arithmetic underflow, and the results of the following computations are interpreted as being exactly ±0, not just really small numbers). e.g.

    System.out.println(-1 / Float.POSITIVE_INFINITY);
    
    -0.0
    

    If we consider the same case with a positive number, we will receive our good old 0:

    System.out.println(1 / Float.POSITIVE_INFINITY);
    
    0.0
    

    ******* Here’s a case where using -0.0 results in something different than when using 0.0:

    System.out.println(1 / 0.0);
    System.out.println(1 / -0.0);
    
    Infinity
    -Infinity
    

    This makes sense if we consider the function 1 / x. As x approaches 0 from the +-side, we should get positive infinity, but as it approaches from the --side, we should get negative infinity. The graph of the function should make this clear:

    (source)

    In math-terms:

    enter image description here

    enter image description here

    This illustrates one significant difference between 0 and -0 in the computational sense.


    Here are some relevant resources, some of which have been brought up already. I’ve included them for the sake of completeness:

    • Wikipedia article on signed zero
    • “What Every Computer Scientist Should Know About Floating-Point Arithmetic” (See Signed Zero section)
    • (PDF) “Much Ado About Nothing’s Sign Bit” – an interesting paper by W. Kahan.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have completed the well known 'news' toutorial included in CI documentation. sometimes double
If I have an array of doubles that each have EXACTLY two decimal places,
I have a some doubles that I want to port into NSDecimalNumber, because I'm
I have three variable declared as doubles: double Delay1 = 0; double Delay2 =
I have to load an array of doubles from a file, multiply each element
I have a sorted array of doubles (latitudes actually) that relatively uniformally spread out
I have code to dynamically allocate an array of 100 doubles to a pointer
I have a parametric curve, say two vectors of doubles where the parameter is
I have a 13x13x100 array, L, of doubles that I write out using csvwrite(L,
I have some code that runs fairly well, but I would like to make

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.