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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:56:48+00:00 2026-05-20T05:56:48+00:00

IEEE floating point numbers have a bit assigned to indicate the sign, which means

  • 0

IEEE floating point numbers have a bit assigned to indicate the sign, which means you can technically have different binary representations of zero (+0 and -0). Is there an arithmetic operation I could do for example in C which result in a negative zero floating point value?

This question is inspired by another which called into question whether you can safely compare 0.0f using ==, and I wondered further if there is are other ways to represent zero which would cause float1 == 0.0f to break for seemingly perfectly equal values.

[Edit] Please, do not comment about the safety of comparing floats for equality! I am not trying to add to that overflowing bucket of duplicate questions.

  • 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-20T05:56:49+00:00Added an answer on May 20, 2026 at 5:56 am

    According to the standard, negative zero exists but it is equal to positive zero. For almost all purposes, the two behave the same way and many consider the existence of a negative to be an implementation detail. There are, however, some functions that behave quite differently, namely division and atan2:

    #include <math.h>
    #include <stdio.h>
    
    int main() {
        double x = 0.0;
        double y = -0.0;
        printf("%.08f == %.08f: %d\n", x, y, x == y);
        printf("%.08f == %.08f: %d\n", 1 / x, 1 / y, 1 / x == 1 / y);
        printf("%.08f == %.08f: %d\n", atan2(x, y), atan2(y, y), atan2(x, y) == atan2(y, y));
    }
    

    The result from this code is:

    0.00000000 == -0.00000000: 1
    1.#INF0000 == -1.#INF0000: 0
    3.14159265 == -3.14159265: 0
    

    This would mean that code would correctly handle certain limits without a need for explicit handling. It’s not certain that relying on this feature for values close to the limits is a good idea, since a simple calculation error can change the sign and make the value far from correct, but you can still take advantage of it if you avoid calculations that would change the sign.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large binary file of ieee 32bit floating point numbers. In python
I have a stream of data which consists of 64-bit IEEE standard 754 floating
I need to represent an IEEE 754-1985 double (64-bit) floating point number in a
I have a set of zip files which contains several ieee-be encoded binary and
This question refers to the IEEE standard floating point numbers used on C/x86. Is
How can I combine 2 ints to a single 32bit IEEE floating point ?
Possible Duplicate: 32 bit hex to 32 bit floating point (IEEE 754) conversion in
Im wondering if atof() can produce a different floating point results based on what
I am writing an (almost) IEEE 854 compliant floating point implementation in TeX (which
I'm learning about the representation of floating-point IEEE 754 numbers, and my textbook says:

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.