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 613031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:57:29+00:00 2026-05-13T17:57:29+00:00

My program seems to be producing some -0 values in place of values that

  • 0

My program seems to be producing some -0 values in place of values that should be 0. How do i stop my program from outputting these values?

Is it as simple as checking if a value is equal to -0 and reassigning it a zero instead? Or is there a more elegant solution?

  • 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-13T17:57:29+00:00Added an answer on May 13, 2026 at 5:57 pm

    Since a tag says visual-c++, it seems you’re running on Windows on an Intel or compatible chip, so integer values of -0 aren’t possible. Maybe you have a floating point value that’s negative but very close to 0, for example -0.000000000000009, and maybe you’re printing it with only a few digits of precision, for example -0.00000. In this case you could do something like:

    if (x > -0.0000001 && x <= 0) x = 0;
    

    Of course you want to do it with more style than that, but that gives you an idea.

    The main text of your question doesn’t say Visual C++ or Windows or Intel. If you’re running on a one’s complement machine, integer values of -0 are possible. Normally -0 compares equal to +0, so the following code would normalize integer zeros:

    if (y == 0) y = 0;  // This looks redundant but it turns a -0 into a +0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that my program does not handle the DownloadComplete event. Can someone guide
I'm trying to write a simple mail retrieval program in python. It seems the
Since a few years, common sense seems to dictate that it's better to program
Ok, so I have some problems with C++ iostreams that feels very odd, but
I have incorporated iAds into a new version of my iOS program. Everything seems
I have one background thread I use for processing separately from the GUI, and
It seems as if read(0, buffer, 255) always returns 1 when reading. In my
I am trying to make my program ignore Ctrl + C in unix which
I've used BackgroundWorkers quite a bit, but I've never experienced this problem before. My
MSVC 10 and MSVC 9 are both generating a level 4 warning message when

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.