Are there any implementations that support negative zero, or reserve it as a trap?

In most implementations of this day and age, a signed integer value that has a bit pattern of 1 for the sign bit and only 0 for the value bits will generally represent the smallest possible value for that signed integer type.

However, since 6.2.6.2p2 states that this is not a requirement:

Which one applies is implementation-defined, as is the value with the sign bit 1 and all the value bits 0 (for the first two) or the familiar bit and all the value 1 bits (for one's complement) is a trap representation or a normal value.

My first question is simple: are there any implementations that use this bit pattern for negative zero or trap representation? If the answer to this question is "no", then the answer to my subsequent questions should also be "no".

Following this question, 6.2.6.2p3 states that when a negative zero is assigned to an object, it may (or may not) convert to normal zero:

It is unknown if these cases actually generate negative zero or normal zero, and whether negative zero is normal zero when stored in an object.

My follow-up questions:

  • Are there any implementations that use trap representation instead of negative zero for this bitmap?
  • Are there any implementations that use negative zero, which is stored as a separate value?
  • Are there any implementations that use negative zero, which is stored as normal zero?

edit for clarification: I am NOT asking what is theoretically possible on a system that uses padding, complement or sign and magnitude signs for signed integers. I can find (and have found) this information in the sections I gave earlier in this question. I ask about what has actually been done .

+1


source to share


1 answer


As brought to my attention by Iskar Jarak in the comments, OS2200, which was recently released in February 2015, has a C implementation known as UCS C, of ​​which the manual docs

  • Corresponding C implementation where-by "... CONFORMANCE / TWOSARITH is not used, negative zero is zero in all 36-bit unsigned integer comparisons using less than (<) or equal (=). Unsigned comparisons using greater (>), ( 2 36 ) - 1 is greater than zero. "
  • questionable C implementation where-by "CONFORMANCE / TWOSARITH causes negative zero, (2 36 ) - 1, to be considered a large unsigned integer by the generated code". As this violates several standard C clauses ( 6.2.6.2p2 , which states that the sign bit has the value - (2 M ) (two's complement) "and" the sign bit has the value - (2 M -1) (one's complement) " , 6.3.1.1p3, which states that "whole shares retain their value, including sign", which contradicts the conversion to large unsigned integer specified in document UCS / OS2200). Hence, this can only match if the negative null bitmap is treated as a trap representation, where the -by undefined behavior is invoked, and therefore the limitations of the standard no longer apply.

Finally,...

Are there any implementations that use this bit pattern for negative null or trap representation?



Yes. The example provided could use this bit pattern for negative zero or trap representation, depending on the compiler's matching options.


For questions 1 & 2 that follow, it follows that UCS C on OS2200 is an example of both of these.

As for question 3, for another day's answer ... My time is over here :)

+1


source







All Articles