Fix spelling of ones' complement.

Message ID 20211116014833.1285001-1-polacek@redhat.com
State New
Headers
Series Fix spelling of ones' complement. |

Commit Message

Marek Polacek Nov. 16, 2021, 1:48 a.m. UTC
  Nitpicking time.  It's spelled "ones' complement" rather than "one's
complement".  I didn't go into config/.

Ok for trunk?

gcc/ChangeLog:

	* doc/implement-c.texi: Fix spelling.
	* doc/md.texi: Likewise.
	* expmed.c (emit_store_flag_int): Likewise.
	* optabs.c (expand_abs): Likewise.
	(expand_one_cmpl_abs_nojump): Likewise.
	* optabs.h (expand_abs): Likewise.
	* tree-ssa-ccp.c (gimple_nop_atomic_bit_test_and_p): Likewise.
---
 gcc/doc/implement-c.texi | 2 +-
 gcc/doc/md.texi          | 2 +-
 gcc/expmed.c             | 2 +-
 gcc/optabs.c             | 4 ++--
 gcc/optabs.h             | 2 +-
 gcc/tree-ssa-ccp.c       | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)


base-commit: a031aaa2ac9d4c74994df085a0d8c79bd55792c9
  

Comments

Li, Pan2 via Gcc-patches Nov. 16, 2021, 2:01 a.m. UTC | #1
> On Nov 15, 2021, at 8:48 PM, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> Nitpicking time.  It's spelled "ones' complement" rather than "one's
> complement". 

Is that so?  I see Wikipedia claims it is, but there are no sources for that claim.  (There is an assertion that it is "discussed at length on the talk page" of an article about number representation, but in fact there is no discussion there at all.)

I have never seen this spelling before, and I very much doubt its validity.  For one thing, why then have "two's complement"?  For another, to pick one random authority, J.E. Thornton in "Design of a computer -- the Control Data 6600" refers to "one's complement" to describe the well known mode used by that machine and its relatives.

	paul
  
Marek Polacek Nov. 16, 2021, 2:19 a.m. UTC | #2
On Tue, Nov 16, 2021 at 02:01:47AM +0000, Koning, Paul via Gcc-patches wrote:
> 
> 
> > On Nov 15, 2021, at 8:48 PM, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > 
> > Nitpicking time.  It's spelled "ones' complement" rather than "one's
> > complement". 
> 
> Is that so?  I see Wikipedia claims it is, but there are no sources for that claim.  (There is an assertion that it is "discussed at length on the talk page" of an article about number representation, but in fact there is no discussion there at all.)
> 
> I have never seen this spelling before, and I very much doubt its validity.  For one thing, why then have "two's complement"?  For another, to pick one random authority, J.E. Thornton in "Design of a computer -- the Control Data 6600" refers to "one's complement" to describe the well known mode used by that machine and its relatives.

Knuth, The Art of Computer Programming Volume 2, page 203-4:

"A two's complement number is complemented with respect to a single
power of 2, while a ones' complement number is complemented with respect
to a long sequence of 1s."

Marek
  
Aldy Hernandez Nov. 16, 2021, 7:03 a.m. UTC | #3
On Tue, Nov 16, 2021, 03:20 Marek Polacek via Gcc-patches <
gcc-patches@gcc.gnu.org> wrote:

> On Tue, Nov 16, 2021 at 02:01:47AM +0000, Koning, Paul via Gcc-patches
> wrote:
> >
> >
> > > On Nov 15, 2021, at 8:48 PM, Marek Polacek via Gcc-patches <
> gcc-patches@gcc.gnu.org> wrote:
> > >
> > > Nitpicking time.  It's spelled "ones' complement" rather than "one's
> > > complement".
> >
> > Is that so?  I see Wikipedia claims it is, but there are no sources for
> that claim.  (There is an assertion that it is "discussed at length on the
> talk page" of an article about number representation, but in fact there is
> no discussion there at all.)
> >
> > I have never seen this spelling before, and I very much doubt its
> validity.  For one thing, why then have "two's complement"?  For another,
> to pick one random authority, J.E. Thornton in "Design of a computer -- the
> Control Data 6600" refers to "one's complement" to describe the well known
> mode used by that machine and its relatives.
>
> Knuth, The Art of Computer Programming Volume 2, page 203-4:
>
> "A two's complement number is complemented with respect to a single
> power of 2, while a ones' complement number is complemented with respect
> to a long sequence of 1s."
>

I think you get to do a drop mike when you pull out Knuth.

:-)

>
>
  
Li, Pan2 via Gcc-patches Nov. 16, 2021, 2:40 p.m. UTC | #4
> On Nov 16, 2021, at 2:03 AM, Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> On Tue, Nov 16, 2021, 03:20 Marek Polacek via Gcc-patches <
> gcc-patches@gcc.gnu.org> wrote:
> 
>> On Tue, Nov 16, 2021 at 02:01:47AM +0000, Koning, Paul via Gcc-patches
>> wrote:
>>> 
>>> 
>>>> On Nov 15, 2021, at 8:48 PM, Marek Polacek via Gcc-patches <
>> gcc-patches@gcc.gnu.org> wrote:
>>>> 
>>>> Nitpicking time.  It's spelled "ones' complement" rather than "one's
>>>> complement".
>>> 
>>> Is that so?  I see Wikipedia claims it is, but there are no sources for
>> that claim.  (There is an assertion that it is "discussed at length on the
>> talk page" of an article about number representation, but in fact there is
>> no discussion there at all.)
>>> 
>>> I have never seen this spelling before, and I very much doubt its
>> validity.  For one thing, why then have "two's complement"?  For another,
>> to pick one random authority, J.E. Thornton in "Design of a computer -- the
>> Control Data 6600" refers to "one's complement" to describe the well known
>> mode used by that machine and its relatives.
>> 
>> Knuth, The Art of Computer Programming Volume 2, page 203-4:
>> 
>> "A two's complement number is complemented with respect to a single
>> power of 2, while a ones' complement number is complemented with respect
>> to a long sequence of 1s."
>> 
> 
> I think you get to do a drop mike when you pull out Knuth.
> 
> :-)

If that were the only source, sure.  But with authoritative sources for both terms (with the ones I quoted being the earlier ones) at the very least there is an argument that both terms are used.  

Some more: DEC PDP-1 handbook (April 1960), page 9: "Negative numbers are represented as the 1's complement of the positive numbers."

Univac 1107 CPU manual, page 2-6: "Next, the adder subtracts the one's complement..."

CDC 160 programming manual (1963), page 2-1: "All arithmetic is binary, one's complement notation".

Incidentally, these are the four of the five machines cited by the Wikipedia article.
  
Aldy Hernandez Nov. 16, 2021, 2:55 p.m. UTC | #5
On Tue, Nov 16, 2021 at 3:40 PM Koning, Paul <Paul.Koning@dell.com> wrote:
>
>
>
> > On Nov 16, 2021, at 2:03 AM, Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >
> > On Tue, Nov 16, 2021, 03:20 Marek Polacek via Gcc-patches <
> > gcc-patches@gcc.gnu.org> wrote:
> >
> >> On Tue, Nov 16, 2021 at 02:01:47AM +0000, Koning, Paul via Gcc-patches
> >> wrote:
> >>>
> >>>
> >>>> On Nov 15, 2021, at 8:48 PM, Marek Polacek via Gcc-patches <
> >> gcc-patches@gcc.gnu.org> wrote:
> >>>>
> >>>> Nitpicking time.  It's spelled "ones' complement" rather than "one's
> >>>> complement".
> >>>
> >>> Is that so?  I see Wikipedia claims it is, but there are no sources for
> >> that claim.  (There is an assertion that it is "discussed at length on the
> >> talk page" of an article about number representation, but in fact there is
> >> no discussion there at all.)
> >>>
> >>> I have never seen this spelling before, and I very much doubt its
> >> validity.  For one thing, why then have "two's complement"?  For another,
> >> to pick one random authority, J.E. Thornton in "Design of a computer -- the
> >> Control Data 6600" refers to "one's complement" to describe the well known
> >> mode used by that machine and its relatives.
> >>
> >> Knuth, The Art of Computer Programming Volume 2, page 203-4:
> >>
> >> "A two's complement number is complemented with respect to a single
> >> power of 2, while a ones' complement number is complemented with respect
> >> to a long sequence of 1s."
> >>
> >
> > I think you get to do a drop mike when you pull out Knuth.
> >
> > :-)
>
> If that were the only source, sure.  But with authoritative sources for both terms (with the ones I quoted being the earlier ones) at the very least there is an argument that both terms are used.
>
> Some more: DEC PDP-1 handbook (April 1960), page 9: "Negative numbers are represented as the 1's complement of the positive numbers."
>
> Univac 1107 CPU manual, page 2-6: "Next, the adder subtracts the one's complement..."
>
> CDC 160 programming manual (1963), page 2-1: "All arithmetic is binary, one's complement notation".
>
> Incidentally, these are the four of the five machines cited by the Wikipedia article.

All sources before Knuth are clearly wrong.  How could they not?
Folks living in the pre-Knuth era lived without a deity.

:-P
  
Bernhard Reutner-Fischer Nov. 16, 2021, 7:57 p.m. UTC | #6
On Tue, 16 Nov 2021 15:55:55 +0100
Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

> All sources before Knuth are clearly wrong.  How could they not?
> Folks living in the pre-Knuth era lived without a deity.
> 
> :-P

Not sure if this one's a compliment.

Speaking of which:

$ git grep -i "complim"
gcc/ChangeLog-2000:	addition over compliments over shifts.
gcc/ada/sem_util.adb:      --  Assume that the main unit does not have a complimentary unit
gcc/ada/sem_util.adb:      --  Obtain the complimentary unit of the main unit
gcc/config/fr30/fr30.c:      /* Convert GCC's comparison operators into the complimentary FR30
gcc/config/mn10300/mn10300.md:  /* Recall that twos-compliment is ones-compliment plus one.  When
gcc/config/nds32/constraints.md:  "A constant whose compliment value is in the range of imm15u
gcc/config/nds32/nds32.md:;; 'ONE_COMPLIMENT' operation
gcc/config/sparc/sparc.h:   compliment of ordered and unordered comparisons, but until generic
gcc/config/visium/visium.h:   compliment of ordered and unordered comparisons, but until generic
gcc/d/expr.cc:  /* Build a compliment expression, where all the bits in the value are
gcc/d/intrinsics.cc:   Variants of `bt' will then update that bit. `btc' compliments the bit, `bts'
gcc/doc/md.texi:A constant whose compliment value is in the range of imm15u
gcc/ipa-reference.c:	  /* Create the complimentary sets.  */
libstdc++-v3/testsuite/data/thirty_years_among_the_dead_preproc.txt:compliment

Maybe someone competent should contemplate to complement the fixes
for ones' two's complement in the above, except the first and last... ;)
  
Mike Stump Nov. 16, 2021, 9:09 p.m. UTC | #7
On Nov 15, 2021, at 5:48 PM, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> Nitpicking time.  It's spelled "ones' complement" rather than "one's
> complement".  I didn't go into config/.
> 
> Ok for trunk?

So, is it two's complement or twos' complement then?  Seems like it should be the same, but  wikipedia suggests it is two's complement, as does google.  If that is wrong, you should go edit it as well.  :-)
  
Marek Polacek Nov. 16, 2021, 9:19 p.m. UTC | #8
On Tue, Nov 16, 2021 at 01:09:15PM -0800, Mike Stump via Gcc-patches wrote:
> On Nov 15, 2021, at 5:48 PM, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > 
> > Nitpicking time.  It's spelled "ones' complement" rather than "one's
> > complement".  I didn't go into config/.
> > 
> > Ok for trunk?
> 
> So, is it two's complement or twos' complement then?  Seems like it should be the same, but  wikipedia suggests it is two's complement, as does google.  If that is wrong, you should go edit it as well.  :-)
 
It is "two's complement":
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584543.html
but Knuth also continues to say that there's "twos' complement notation",
which "has radix 3 and complementation with respect to (2...22)_3."


It's not lost on me how inconsequential this patch is; I'm happy to just
drop it and let the copy editor in me sleep.

Marek
  
Eric Botcazou Nov. 16, 2021, 11:39 p.m. UTC | #9
> Nitpicking time.  It's spelled "ones' complement" rather than "one's
> complement".  I didn't go into config/.
> 
> Ok for trunk?
> 
> gcc/ChangeLog:
> 
> 	* doc/implement-c.texi: Fix spelling.
> 	* doc/md.texi: Likewise.
> 	* expmed.c (emit_store_flag_int): Likewise.
> 	* optabs.c (expand_abs): Likewise.
> 	(expand_one_cmpl_abs_nojump): Likewise.
> 	* optabs.h (expand_abs): Likewise.
> 	* tree-ssa-ccp.c (gimple_nop_atomic_bit_test_and_p): Likewise.

IMO either you change them all or you change none, any intermediate stage is 
worse than the current situation, which is probably OK for 99.99% of people.
  
Li, Pan2 via Gcc-patches Nov. 17, 2021, 1:35 a.m. UTC | #10
> On Nov 16, 2021, at 4:19 PM, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> On Tue, Nov 16, 2021 at 01:09:15PM -0800, Mike Stump via Gcc-patches wrote:
>> On Nov 15, 2021, at 5:48 PM, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>> 
>>> Nitpicking time.  It's spelled "ones' complement" rather than "one's
>>> complement".  I didn't go into config/.
>>> 
>>> Ok for trunk?
>> 
>> So, is it two's complement or twos' complement then?  Seems like it should be the same, but  wikipedia suggests it is two's complement, as does google.  If that is wrong, you should go edit it as well.  :-)
> 
> It is "two's complement":
> https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584543.html
> but Knuth also continues to say that there's "twos' complement notation",
> which "has radix 3 and complementation with respect to (2...22)_3."
> 
> 
> It's not lost on me how inconsequential this patch is; I'm happy to just
> drop it and let the copy editor in me sleep.
> 
> Marek

To me it isn't so much a question of copy editing, but rather the fact that there clearly are two spellings, and if anything the one in the current text is the common one and the Knuth one found less often (perhaps only in Knuth).  My answer is to go fix Wikipedia, if possible.

	paul
  

Patch

diff --git a/gcc/doc/implement-c.texi b/gcc/doc/implement-c.texi
index b656ac8ec4f..5dcd79004de 100644
--- a/gcc/doc/implement-c.texi
+++ b/gcc/doc/implement-c.texi
@@ -236,7 +236,7 @@  GCC does not support any extended integer types.
 
 @item
 @cite{Whether signed integer types are represented using sign and magnitude,
-two's complement, or one's complement, and whether the extraordinary value
+two's complement, or ones' complement, and whether the extraordinary value
 is a trap representation or an ordinary value (C99 and C11 6.2.6.2).}
 
 GCC supports only two's complement integer types, and all bit patterns
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 41f1850bf6e..64a4cc0834e 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -1930,7 +1930,7 @@  A 3-bit unsigned integer constant.
 A 6-bit unsigned integer constant.
 
 @item CnL
-One's complement of a 6-bit unsigned integer constant.
+Ones' complement of a 6-bit unsigned integer constant.
 
 @item CmL
 Two's complement of a 6-bit unsigned integer constant.
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 4abce11b647..6f19da6ef92 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -5940,7 +5940,7 @@  emit_store_flag_int (rtx target, rtx subtarget, enum rtx_code code, rtx op0,
 	}
 
       /* If we couldn't do it that way, for NE we can "or" the two's complement
-	 of the value with itself.  For EQ, we take the one's complement of
+	 of the value with itself.  For EQ, we take the ones' complement of
 	 that "or", which is an extra insn, so we only handle EQ if branches
 	 are expensive.  */
 
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 019bbb62882..d3d801fb96d 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -3742,7 +3742,7 @@  expand_abs (machine_mode mode, rtx op0, rtx target,
   return target;
 }
 
-/* Emit code to compute the one's complement absolute value of OP0
+/* Emit code to compute the ones' complement absolute value of OP0
    (if (OP0 < 0) OP0 = ~OP0), with result to TARGET if convenient.
    (TARGET may be NULL_RTX.)  The return value says where the result
    actually is to be found.
@@ -3775,7 +3775,7 @@  expand_one_cmpl_abs_nojump (machine_mode mode, rtx op0, rtx target)
       delete_insns_since (last);
     }
 
-  /* If this machine has expensive jumps, we can do one's complement
+  /* If this machine has expensive jumps, we can do ones' complement
      absolute value of X as (((signed) x >> (W-1)) ^ x).  */
 
   scalar_int_mode int_mode;
diff --git a/gcc/optabs.h b/gcc/optabs.h
index 3bbceff92d9..9ed96944ebe 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -219,7 +219,7 @@  extern rtx expand_unop (machine_mode, optab, rtx, rtx, int);
 extern rtx expand_abs_nojump (machine_mode, rtx, rtx, int);
 extern rtx expand_abs (machine_mode, rtx, rtx, int, int);
 
-/* Expand the one's complement absolute value operation.  */
+/* Expand the ones' complement absolute value operation.  */
 extern rtx expand_one_cmpl_abs_nojump (machine_mode, rtx, rtx);
 
 /* Expand the copysign operation.  */
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 0666dc652d0..8d3f68b1367 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -3341,7 +3341,7 @@  extern bool gimple_nop_atomic_bit_test_and_p (tree, tree *,
    in there), and/or if mask_2 is a power of 2 constant.
    Similarly for xor instead of or, use ATOMIC_BIT_TEST_AND_COMPLEMENT
    in that case.  And similarly for and instead of or, except that
-   the second argument to the builtin needs to be one's complement
+   the second argument to the builtin needs to be ones' complement
    of the mask instead of mask.  */
 
 static void