8

I am reading revision 4 of the two's-complement proposal (adopted by C++20), and I have some questions.

In the introduction, it says:

  • Status-quo Signed integer arithmetic remains non-commutative in general (though some implementations may guarantee that it is).

Does it really mean "non-commutative", as in a + b versus b + a? Or should that read "non-associative"?

It also says:

  • Change Conversion from signed to unsigned is always well-defined: the result is the unique value of the destination type that is congruent to the source integer modulo 2^N.

Hasn't signed-to-unsigned conversion been well-defined in precisely this way since the beginning of time? Should that read "conversion from unsigned to signed"?

Is there anything else in the list of changes that is missing or mis-stated?

curiousguy
  • 8,038
  • 2
  • 40
  • 58
Nemo
  • 70,042
  • 10
  • 116
  • 153
  • I'm voting to close this question as off-topic because this question is unlikely to helpful to anybody outside of the specific author of the paper in question, and not even then because the design was already adopted into C++20 by [P1236](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1236r1.html). – Barry Sep 20 '19 at 18:00
  • Like yes, it should read non-associative and the change was to unsigned-to-signed. – Barry Sep 20 '19 at 18:03
  • 2
    That's just two typos ... Sometimes we have to accept that humans make mistakes – L. F. Sep 21 '19 at 01:19
  • @Barry These Q are helpful if other ppl with the same Q can find that Q and realize that they are not alone asking these Q. – curiousguy Sep 21 '19 at 14:21

1 Answers1

2

Note that it wasn't P0907 that was adopted - it was P1236.


Or should that read "non-associative"?

Yes.

Should that read "conversion from unsigned to signed"?

Yes. If you look at P1236R1, you can see that the rule changed from:

If the destination type is unsigned, the resulting value is the least unsigned integer congruent to the source integer (modulo 2n where n is the number of bits used to represent the unsigned type).

If the destination type is signed, the value is unchanged if it can be represented in the destination type; otherwise, the value is implementation-defined.

to:

Otherwise, the result is the unique value of the destination type that is congruent to the source integer modulo 2N, where N is the range exponent of the destination type.

Community
  • 1
  • 1
Barry
  • 286,269
  • 29
  • 621
  • 977