What is the meaning of “producing negative zeroes” in a system that doesn't support it?What does “static” mean in C?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Does the C99 standard guaranteed the binary representation of unsigned int?Can a int16_t to int conversation result in implementation-defined behavior?Is the non-negative range of a signed C++ integer at least as big as the negative range?Are there any implementations that support a negative zero, or reserve it as a trap representation?What does POSIX mean by “two's complement representation” in stdint.h?Can bitwise operators have undefined behavior?When are bitwise operations undefined in C?Is it possible to test whether a type supports negative zero in C++ at compile time?

Applicability of Single Responsibility Principle

Pre-amplifier input protection

What does "I’d sit this one out, Cap," imply or mean in the context?

Is oxalic acid dihydrate considered a primary acid standard in analytical chemistry?

How do we know the LHC results are robust?

Go Pregnant or Go Home

How does the UK government determine the size of a mandate?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Do sorcerers' Subtle Spells require a skill check to be unseen?

Trouble understanding the speech of overseas colleagues

Is the destination of a commercial flight important for the pilot?

How did Arya survive the stabbing?

Why, precisely, is argon used in neutrino experiments?

Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?

Opposite of a diet

How to run a prison with the smallest amount of guards?

Proof of work - lottery approach

Anatomically Correct Strange Women In Ponds Distributing Swords

How can we prove that any integral in the set of non-elementary integrals cannot be expressed in the form of elementary functions?

How do I extract a value from a time formatted value in excel?

Integer addition + constant, is it a group?

How do scammers retract money, while you can’t?

Crossing the line between justified force and brutality

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?



What is the meaning of “producing negative zeroes” in a system that doesn't support it?


What does “static” mean in C?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Does the C99 standard guaranteed the binary representation of unsigned int?Can a int16_t to int conversation result in implementation-defined behavior?Is the non-negative range of a signed C++ integer at least as big as the negative range?Are there any implementations that support a negative zero, or reserve it as a trap representation?What does POSIX mean by “two's complement representation” in stdint.h?Can bitwise operators have undefined behavior?When are bitwise operations undefined in C?Is it possible to test whether a type supports negative zero in C++ at compile time?













19















C17 6.2.6.2/4 says:




If the implementation does not support negative zeros, the behavior of the &, |, ^, ~, <<,
and >> operators with operands that would produce such a value is undefined.




If I have a 2's complement system, it does not support negative zeroes. And it always utilizes all possible combinations of a binary number to express a value. Therefore it is impossible to ever produce a negative zero, no matter which bitwise operation that is used. So what is the meaning of this text?



My take is that this part refers to systems with 1's complement or signed magnitude that does not support negative zeroes, but instead use a padding bit or trap representation. Is this correct?










share|improve this question






















  • What do you understand by "trap representation" ?

    – alinsoar
    Mar 7 at 14:25











  • I also read lots of times about "tr" but I never saw one concretely, so I cannot understand what that means. I read articles about this, but I do not understand what is a trap representation. On X86 processors are there trs ?

    – alinsoar
    Mar 7 at 14:57







  • 1





    @alinsoar I don't know of any implementation in the real world that uses them for plain integers (floating point is another story). Mostly it is something invented by C standard committee language lawyers, like they invented the need to support 1's complement and signed magnitude computers.

    – Lundin
    Mar 7 at 15:24






  • 2





    I don't get why there are complicated answers and why this is even a question, doesn't it just mean exactly what it says? You are asking about a system which does not contain the notion of a negative zero, so isn't that exactly what that section would be describing? Meaning, just as your quoted section says... the behavior that would produce a negative zero (that behavior which doesn't exist in your case) has undefined results. As simple as that. Analogy: Enacting a law saying "Anyone who slays a boogeyman gets a week in jail" is not suddenly confusing simply because of a lack of boogeymen.

    – Aaron
    Mar 7 at 19:44






  • 1





    @Aaron Not exactly. At the bottom of my answer is an example that shows this can happen, and when it does undefined behavior is invoked.

    – dbush
    Mar 7 at 20:31















19















C17 6.2.6.2/4 says:




If the implementation does not support negative zeros, the behavior of the &, |, ^, ~, <<,
and >> operators with operands that would produce such a value is undefined.




If I have a 2's complement system, it does not support negative zeroes. And it always utilizes all possible combinations of a binary number to express a value. Therefore it is impossible to ever produce a negative zero, no matter which bitwise operation that is used. So what is the meaning of this text?



My take is that this part refers to systems with 1's complement or signed magnitude that does not support negative zeroes, but instead use a padding bit or trap representation. Is this correct?










share|improve this question






















  • What do you understand by "trap representation" ?

    – alinsoar
    Mar 7 at 14:25











  • I also read lots of times about "tr" but I never saw one concretely, so I cannot understand what that means. I read articles about this, but I do not understand what is a trap representation. On X86 processors are there trs ?

    – alinsoar
    Mar 7 at 14:57







  • 1





    @alinsoar I don't know of any implementation in the real world that uses them for plain integers (floating point is another story). Mostly it is something invented by C standard committee language lawyers, like they invented the need to support 1's complement and signed magnitude computers.

    – Lundin
    Mar 7 at 15:24






  • 2





    I don't get why there are complicated answers and why this is even a question, doesn't it just mean exactly what it says? You are asking about a system which does not contain the notion of a negative zero, so isn't that exactly what that section would be describing? Meaning, just as your quoted section says... the behavior that would produce a negative zero (that behavior which doesn't exist in your case) has undefined results. As simple as that. Analogy: Enacting a law saying "Anyone who slays a boogeyman gets a week in jail" is not suddenly confusing simply because of a lack of boogeymen.

    – Aaron
    Mar 7 at 19:44






  • 1





    @Aaron Not exactly. At the bottom of my answer is an example that shows this can happen, and when it does undefined behavior is invoked.

    – dbush
    Mar 7 at 20:31













19












19








19


1






C17 6.2.6.2/4 says:




If the implementation does not support negative zeros, the behavior of the &, |, ^, ~, <<,
and >> operators with operands that would produce such a value is undefined.




If I have a 2's complement system, it does not support negative zeroes. And it always utilizes all possible combinations of a binary number to express a value. Therefore it is impossible to ever produce a negative zero, no matter which bitwise operation that is used. So what is the meaning of this text?



My take is that this part refers to systems with 1's complement or signed magnitude that does not support negative zeroes, but instead use a padding bit or trap representation. Is this correct?










share|improve this question














C17 6.2.6.2/4 says:




If the implementation does not support negative zeros, the behavior of the &, |, ^, ~, <<,
and >> operators with operands that would produce such a value is undefined.




If I have a 2's complement system, it does not support negative zeroes. And it always utilizes all possible combinations of a binary number to express a value. Therefore it is impossible to ever produce a negative zero, no matter which bitwise operation that is used. So what is the meaning of this text?



My take is that this part refers to systems with 1's complement or signed magnitude that does not support negative zeroes, but instead use a padding bit or trap representation. Is this correct?







c language-lawyer bitwise-operators signed twos-complement






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 12:55









LundinLundin

112k17163271




112k17163271












  • What do you understand by "trap representation" ?

    – alinsoar
    Mar 7 at 14:25











  • I also read lots of times about "tr" but I never saw one concretely, so I cannot understand what that means. I read articles about this, but I do not understand what is a trap representation. On X86 processors are there trs ?

    – alinsoar
    Mar 7 at 14:57







  • 1





    @alinsoar I don't know of any implementation in the real world that uses them for plain integers (floating point is another story). Mostly it is something invented by C standard committee language lawyers, like they invented the need to support 1's complement and signed magnitude computers.

    – Lundin
    Mar 7 at 15:24






  • 2





    I don't get why there are complicated answers and why this is even a question, doesn't it just mean exactly what it says? You are asking about a system which does not contain the notion of a negative zero, so isn't that exactly what that section would be describing? Meaning, just as your quoted section says... the behavior that would produce a negative zero (that behavior which doesn't exist in your case) has undefined results. As simple as that. Analogy: Enacting a law saying "Anyone who slays a boogeyman gets a week in jail" is not suddenly confusing simply because of a lack of boogeymen.

    – Aaron
    Mar 7 at 19:44






  • 1





    @Aaron Not exactly. At the bottom of my answer is an example that shows this can happen, and when it does undefined behavior is invoked.

    – dbush
    Mar 7 at 20:31

















  • What do you understand by "trap representation" ?

    – alinsoar
    Mar 7 at 14:25











  • I also read lots of times about "tr" but I never saw one concretely, so I cannot understand what that means. I read articles about this, but I do not understand what is a trap representation. On X86 processors are there trs ?

    – alinsoar
    Mar 7 at 14:57







  • 1





    @alinsoar I don't know of any implementation in the real world that uses them for plain integers (floating point is another story). Mostly it is something invented by C standard committee language lawyers, like they invented the need to support 1's complement and signed magnitude computers.

    – Lundin
    Mar 7 at 15:24






  • 2





    I don't get why there are complicated answers and why this is even a question, doesn't it just mean exactly what it says? You are asking about a system which does not contain the notion of a negative zero, so isn't that exactly what that section would be describing? Meaning, just as your quoted section says... the behavior that would produce a negative zero (that behavior which doesn't exist in your case) has undefined results. As simple as that. Analogy: Enacting a law saying "Anyone who slays a boogeyman gets a week in jail" is not suddenly confusing simply because of a lack of boogeymen.

    – Aaron
    Mar 7 at 19:44






  • 1





    @Aaron Not exactly. At the bottom of my answer is an example that shows this can happen, and when it does undefined behavior is invoked.

    – dbush
    Mar 7 at 20:31
















What do you understand by "trap representation" ?

– alinsoar
Mar 7 at 14:25





What do you understand by "trap representation" ?

– alinsoar
Mar 7 at 14:25













I also read lots of times about "tr" but I never saw one concretely, so I cannot understand what that means. I read articles about this, but I do not understand what is a trap representation. On X86 processors are there trs ?

– alinsoar
Mar 7 at 14:57






I also read lots of times about "tr" but I never saw one concretely, so I cannot understand what that means. I read articles about this, but I do not understand what is a trap representation. On X86 processors are there trs ?

– alinsoar
Mar 7 at 14:57





1




1





@alinsoar I don't know of any implementation in the real world that uses them for plain integers (floating point is another story). Mostly it is something invented by C standard committee language lawyers, like they invented the need to support 1's complement and signed magnitude computers.

– Lundin
Mar 7 at 15:24





@alinsoar I don't know of any implementation in the real world that uses them for plain integers (floating point is another story). Mostly it is something invented by C standard committee language lawyers, like they invented the need to support 1's complement and signed magnitude computers.

– Lundin
Mar 7 at 15:24




2




2





I don't get why there are complicated answers and why this is even a question, doesn't it just mean exactly what it says? You are asking about a system which does not contain the notion of a negative zero, so isn't that exactly what that section would be describing? Meaning, just as your quoted section says... the behavior that would produce a negative zero (that behavior which doesn't exist in your case) has undefined results. As simple as that. Analogy: Enacting a law saying "Anyone who slays a boogeyman gets a week in jail" is not suddenly confusing simply because of a lack of boogeymen.

– Aaron
Mar 7 at 19:44





I don't get why there are complicated answers and why this is even a question, doesn't it just mean exactly what it says? You are asking about a system which does not contain the notion of a negative zero, so isn't that exactly what that section would be describing? Meaning, just as your quoted section says... the behavior that would produce a negative zero (that behavior which doesn't exist in your case) has undefined results. As simple as that. Analogy: Enacting a law saying "Anyone who slays a boogeyman gets a week in jail" is not suddenly confusing simply because of a lack of boogeymen.

– Aaron
Mar 7 at 19:44




1




1





@Aaron Not exactly. At the bottom of my answer is an example that shows this can happen, and when it does undefined behavior is invoked.

– dbush
Mar 7 at 20:31





@Aaron Not exactly. At the bottom of my answer is an example that shows this can happen, and when it does undefined behavior is invoked.

– dbush
Mar 7 at 20:31












2 Answers
2






active

oldest

votes


















12














Your interpretation is correct.



Going up to paragraph 2 of 6.2.6.2:




For signed integer types, the bits of the object
representation shall be divided into three groups: value bits,
padding bits, and the sign bit. There need not be any
padding bits; signed char shall not have any padding bits.
There shall be exactly one sign bit. Each bit that is a
value bit shall have the same value as the same bit in the
object representation of the corresponding unsigned type (if there are
M value bits in the signed type and N in the unsigned type, then M ≤ N
). If the sign bit is zero, it shall not affect the resulting
value. If the sign bit is one, the value shall be modified
in one of the following ways:



  • the corresponding value with sign bit 0 is negated ( sign and magnitude );

  • the sign bit has the value − (2M)( two’s complement );

  • the sign bit has the value − (2M − 1) ( ones’ complement ).

Which of these applies is implementation-defined, as is whether the
value with sign bit 1 and all value bits zero (for the first
two), or with sign bit and all value bits 1 (for ones’
complement), is a trap representation or a normal value. In
the case of sign and magnitude and ones’ complement, if this
representation is a normal value it is called a negative zero.




This means an implementation using either one's complement or sign and magnitude has, for a given size integer type, a specific representation which must be either negative zero or a trap representation. It's then up to the implementation to choose which one of those applies.



As an example, suppose a system has sign and magnitude representation and a 32 bit int with no padding. Then the representation that would be negative zero, if it is supported, is 0x80000000.



Now suppose the following operations are performed:



 int x = 0x7fffffff;
x = ~x;


If the implementation supports negative zero, the ~ operator will generate -0 as the result and store it in x. If it does not, it creates a trap representation and invokes undefined behavior as per paragraph 4.






share|improve this answer
































    14














    Yes, I think your interpretation is correct. In two's complement, that are no operations that could generate a negative zero, because the concept here doesn't exist: any value that has the sign bit set is necessarily less than 0.



    BTW: It is very likely that the exotic sign representations will be removed from C2x, so all of this will disappear.






    share|improve this answer


















    • 1





      I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

      – Marc van Leeuwen
      Mar 7 at 15:16












    • @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

      – John Bollinger
      Mar 7 at 15:47







    • 1





      @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

      – Jens Gustedt
      Mar 7 at 17:19











    • @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

      – Jens Gustedt
      Mar 7 at 17:23






    • 2





      @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

      – supercat
      Mar 7 at 22:04










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044324%2fwhat-is-the-meaning-of-producing-negative-zeroes-in-a-system-that-doesnt-supp%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    12














    Your interpretation is correct.



    Going up to paragraph 2 of 6.2.6.2:




    For signed integer types, the bits of the object
    representation shall be divided into three groups: value bits,
    padding bits, and the sign bit. There need not be any
    padding bits; signed char shall not have any padding bits.
    There shall be exactly one sign bit. Each bit that is a
    value bit shall have the same value as the same bit in the
    object representation of the corresponding unsigned type (if there are
    M value bits in the signed type and N in the unsigned type, then M ≤ N
    ). If the sign bit is zero, it shall not affect the resulting
    value. If the sign bit is one, the value shall be modified
    in one of the following ways:



    • the corresponding value with sign bit 0 is negated ( sign and magnitude );

    • the sign bit has the value − (2M)( two’s complement );

    • the sign bit has the value − (2M − 1) ( ones’ complement ).

    Which of these applies is implementation-defined, as is whether the
    value with sign bit 1 and all value bits zero (for the first
    two), or with sign bit and all value bits 1 (for ones’
    complement), is a trap representation or a normal value. In
    the case of sign and magnitude and ones’ complement, if this
    representation is a normal value it is called a negative zero.




    This means an implementation using either one's complement or sign and magnitude has, for a given size integer type, a specific representation which must be either negative zero or a trap representation. It's then up to the implementation to choose which one of those applies.



    As an example, suppose a system has sign and magnitude representation and a 32 bit int with no padding. Then the representation that would be negative zero, if it is supported, is 0x80000000.



    Now suppose the following operations are performed:



     int x = 0x7fffffff;
    x = ~x;


    If the implementation supports negative zero, the ~ operator will generate -0 as the result and store it in x. If it does not, it creates a trap representation and invokes undefined behavior as per paragraph 4.






    share|improve this answer





























      12














      Your interpretation is correct.



      Going up to paragraph 2 of 6.2.6.2:




      For signed integer types, the bits of the object
      representation shall be divided into three groups: value bits,
      padding bits, and the sign bit. There need not be any
      padding bits; signed char shall not have any padding bits.
      There shall be exactly one sign bit. Each bit that is a
      value bit shall have the same value as the same bit in the
      object representation of the corresponding unsigned type (if there are
      M value bits in the signed type and N in the unsigned type, then M ≤ N
      ). If the sign bit is zero, it shall not affect the resulting
      value. If the sign bit is one, the value shall be modified
      in one of the following ways:



      • the corresponding value with sign bit 0 is negated ( sign and magnitude );

      • the sign bit has the value − (2M)( two’s complement );

      • the sign bit has the value − (2M − 1) ( ones’ complement ).

      Which of these applies is implementation-defined, as is whether the
      value with sign bit 1 and all value bits zero (for the first
      two), or with sign bit and all value bits 1 (for ones’
      complement), is a trap representation or a normal value. In
      the case of sign and magnitude and ones’ complement, if this
      representation is a normal value it is called a negative zero.




      This means an implementation using either one's complement or sign and magnitude has, for a given size integer type, a specific representation which must be either negative zero or a trap representation. It's then up to the implementation to choose which one of those applies.



      As an example, suppose a system has sign and magnitude representation and a 32 bit int with no padding. Then the representation that would be negative zero, if it is supported, is 0x80000000.



      Now suppose the following operations are performed:



       int x = 0x7fffffff;
      x = ~x;


      If the implementation supports negative zero, the ~ operator will generate -0 as the result and store it in x. If it does not, it creates a trap representation and invokes undefined behavior as per paragraph 4.






      share|improve this answer



























        12












        12








        12







        Your interpretation is correct.



        Going up to paragraph 2 of 6.2.6.2:




        For signed integer types, the bits of the object
        representation shall be divided into three groups: value bits,
        padding bits, and the sign bit. There need not be any
        padding bits; signed char shall not have any padding bits.
        There shall be exactly one sign bit. Each bit that is a
        value bit shall have the same value as the same bit in the
        object representation of the corresponding unsigned type (if there are
        M value bits in the signed type and N in the unsigned type, then M ≤ N
        ). If the sign bit is zero, it shall not affect the resulting
        value. If the sign bit is one, the value shall be modified
        in one of the following ways:



        • the corresponding value with sign bit 0 is negated ( sign and magnitude );

        • the sign bit has the value − (2M)( two’s complement );

        • the sign bit has the value − (2M − 1) ( ones’ complement ).

        Which of these applies is implementation-defined, as is whether the
        value with sign bit 1 and all value bits zero (for the first
        two), or with sign bit and all value bits 1 (for ones’
        complement), is a trap representation or a normal value. In
        the case of sign and magnitude and ones’ complement, if this
        representation is a normal value it is called a negative zero.




        This means an implementation using either one's complement or sign and magnitude has, for a given size integer type, a specific representation which must be either negative zero or a trap representation. It's then up to the implementation to choose which one of those applies.



        As an example, suppose a system has sign and magnitude representation and a 32 bit int with no padding. Then the representation that would be negative zero, if it is supported, is 0x80000000.



        Now suppose the following operations are performed:



         int x = 0x7fffffff;
        x = ~x;


        If the implementation supports negative zero, the ~ operator will generate -0 as the result and store it in x. If it does not, it creates a trap representation and invokes undefined behavior as per paragraph 4.






        share|improve this answer















        Your interpretation is correct.



        Going up to paragraph 2 of 6.2.6.2:




        For signed integer types, the bits of the object
        representation shall be divided into three groups: value bits,
        padding bits, and the sign bit. There need not be any
        padding bits; signed char shall not have any padding bits.
        There shall be exactly one sign bit. Each bit that is a
        value bit shall have the same value as the same bit in the
        object representation of the corresponding unsigned type (if there are
        M value bits in the signed type and N in the unsigned type, then M ≤ N
        ). If the sign bit is zero, it shall not affect the resulting
        value. If the sign bit is one, the value shall be modified
        in one of the following ways:



        • the corresponding value with sign bit 0 is negated ( sign and magnitude );

        • the sign bit has the value − (2M)( two’s complement );

        • the sign bit has the value − (2M − 1) ( ones’ complement ).

        Which of these applies is implementation-defined, as is whether the
        value with sign bit 1 and all value bits zero (for the first
        two), or with sign bit and all value bits 1 (for ones’
        complement), is a trap representation or a normal value. In
        the case of sign and magnitude and ones’ complement, if this
        representation is a normal value it is called a negative zero.




        This means an implementation using either one's complement or sign and magnitude has, for a given size integer type, a specific representation which must be either negative zero or a trap representation. It's then up to the implementation to choose which one of those applies.



        As an example, suppose a system has sign and magnitude representation and a 32 bit int with no padding. Then the representation that would be negative zero, if it is supported, is 0x80000000.



        Now suppose the following operations are performed:



         int x = 0x7fffffff;
        x = ~x;


        If the implementation supports negative zero, the ~ operator will generate -0 as the result and store it in x. If it does not, it creates a trap representation and invokes undefined behavior as per paragraph 4.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 7 at 14:27

























        answered Mar 7 at 13:28









        dbushdbush

        103k13108145




        103k13108145























            14














            Yes, I think your interpretation is correct. In two's complement, that are no operations that could generate a negative zero, because the concept here doesn't exist: any value that has the sign bit set is necessarily less than 0.



            BTW: It is very likely that the exotic sign representations will be removed from C2x, so all of this will disappear.






            share|improve this answer


















            • 1





              I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

              – Marc van Leeuwen
              Mar 7 at 15:16












            • @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

              – John Bollinger
              Mar 7 at 15:47







            • 1





              @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

              – Jens Gustedt
              Mar 7 at 17:19











            • @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

              – Jens Gustedt
              Mar 7 at 17:23






            • 2





              @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

              – supercat
              Mar 7 at 22:04















            14














            Yes, I think your interpretation is correct. In two's complement, that are no operations that could generate a negative zero, because the concept here doesn't exist: any value that has the sign bit set is necessarily less than 0.



            BTW: It is very likely that the exotic sign representations will be removed from C2x, so all of this will disappear.






            share|improve this answer


















            • 1





              I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

              – Marc van Leeuwen
              Mar 7 at 15:16












            • @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

              – John Bollinger
              Mar 7 at 15:47







            • 1





              @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

              – Jens Gustedt
              Mar 7 at 17:19











            • @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

              – Jens Gustedt
              Mar 7 at 17:23






            • 2





              @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

              – supercat
              Mar 7 at 22:04













            14












            14








            14







            Yes, I think your interpretation is correct. In two's complement, that are no operations that could generate a negative zero, because the concept here doesn't exist: any value that has the sign bit set is necessarily less than 0.



            BTW: It is very likely that the exotic sign representations will be removed from C2x, so all of this will disappear.






            share|improve this answer













            Yes, I think your interpretation is correct. In two's complement, that are no operations that could generate a negative zero, because the concept here doesn't exist: any value that has the sign bit set is necessarily less than 0.



            BTW: It is very likely that the exotic sign representations will be removed from C2x, so all of this will disappear.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 7 at 13:12









            Jens GustedtJens Gustedt

            65.9k275144




            65.9k275144







            • 1





              I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

              – Marc van Leeuwen
              Mar 7 at 15:16












            • @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

              – John Bollinger
              Mar 7 at 15:47







            • 1





              @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

              – Jens Gustedt
              Mar 7 at 17:19











            • @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

              – Jens Gustedt
              Mar 7 at 17:23






            • 2





              @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

              – supercat
              Mar 7 at 22:04












            • 1





              I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

              – Marc van Leeuwen
              Mar 7 at 15:16












            • @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

              – John Bollinger
              Mar 7 at 15:47







            • 1





              @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

              – Jens Gustedt
              Mar 7 at 17:19











            • @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

              – Jens Gustedt
              Mar 7 at 17:23






            • 2





              @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

              – supercat
              Mar 7 at 22:04







            1




            1





            I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

            – Marc van Leeuwen
            Mar 7 at 15:16






            I'm amazed at why language designers seem to be so worried about backwards hardware compatibility. I don't think any computer hardware commercialised during the current century uses anything but twos complement representation, and one can be rather certain that nobody is going to write a compiler for a new language version designed to work on old hardware (the opposite, running an old language version on new hardware, of course happens a lot). So language designers could have assumed twos complement behaviour for a long time, but apparently they are only coming around to doing that just now.

            – Marc van Leeuwen
            Mar 7 at 15:16














            @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

            – John Bollinger
            Mar 7 at 15:47






            @Jens, is the committee then considering specifying two's complement representation as the only option? For another way the exotic sign representations might be removed would be to delete the details, but simply make the representations of signed integers implementation defined (or even unspecified) when the sign bit is set.

            – John Bollinger
            Mar 7 at 15:47





            1




            1





            @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

            – Jens Gustedt
            Mar 7 at 17:19





            @MarcvanLeeuwen, the problem was that it is difficult to assess if there are still such implementations around. And, as always, if people would more engage in committee work, things might go smoother.

            – Jens Gustedt
            Mar 7 at 17:19













            @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

            – Jens Gustedt
            Mar 7 at 17:23





            @JohnBollinger yes, it should be two's complement, see open-std.org/jtc1/sc22/wg14/www/docs/n2330.pdf

            – Jens Gustedt
            Mar 7 at 17:23




            2




            2





            @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

            – supercat
            Mar 7 at 22:04





            @JohnBollinger: If I had my druthers, the Standard would recognize a category of implementation where all integer types' representations were either consistently big-endian or little-endian without padding and signed integers were two's-complement, and a broader category where integer types could be stored in any fashion the implementation sees fit. I see no reason to explicitly allow or exclude any particular forms of representation from the broader category.

            – supercat
            Mar 7 at 22:04

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044324%2fwhat-is-the-meaning-of-producing-negative-zeroes-in-a-system-that-doesnt-supp%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved