Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expr.unary.op] Cleanup of {ones',two's} complement, and of "operator" #5998

Merged
merged 2 commits into from Dec 15, 2022

Conversation

tkoeppe
Copy link
Contributor

@tkoeppe tkoeppe commented Nov 22, 2022

We are currently using the term "unary complement" to refer to the "~" operator without ever giving it that name.

This change removes unnecessary uses of the terms "unary" and "complement", but adds notes that make referenes to "ones'/two's complement".

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 22, 2022

@opensdh could you please have a look?

source/expressions.tex Outdated Show resolved Hide resolved
@@ -4662,6 +4662,9 @@
of an unsigned quantity is computed by subtracting its value from $2^n$,
where $n$ is the number of bits in the promoted operand. The type of the
result is the type of the promoted operand.
\begin{note}
The result is the two's complement function of the operand.
Copy link
Contributor

@opensdh opensdh Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should differ in only the operative word: the "considered as unsigned" (or however we choose to phrase that) still applies when we're thinking of this as a complement operation (rather than merely commenting that negative numbers are represented by the two's complement in this system), and the result is not itself a function (although I see that [expr.bit.and] and friends say "of" when they really mean "applied to").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The sine of 0 is 0" vs "the sine applied to 0 is 0"... both work, don't they? Yes, "of" has two meanings (function declaration vs evaluation), but it's not wrong to use for evaluation.

I don't quite understand the first part; could you suggest a complete note?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, I'm happy to lose the notes entirely now that we got rid of "unary"!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but no one would say "the error function of 0.5" but rather "the error function{,'s value, evaluated} at 0.5" because "function of" is confusing. (It is funny, though, that even English has declaration-follows-use here.)

I just meant

The result is the two's complement of the operand (both considered as unsigned).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, that's what you suggested above. PTAL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me; you might want to check that no one has qualms about "considering" things as unsigned in a note (even though the actual bit behavior should be pretty obvious to all).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensmaurer, @burblebee, @jfbastien: any qualms about "considering" things as unsigned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still haven't resolved whether there are qualms!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the phrasing. It's a note.

Copy link
Contributor

@opensdh opensdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the notes were helpful (partly for people looking for the old definitions), but this small change seems to be an improvement.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Nov 22, 2022

We can keep the notes if you find them useful!

@tkoeppe tkoeppe changed the title [expr.unary.op] Notes naming unary ops as {ones',two's} complement [expr.unary.op] Cleanup of {ones',two's} complement, and of "operator" Nov 22, 2022
source/expressions.tex Outdated Show resolved Hide resolved
We are currently using the term "unary complement operator" to refer
to the "~" operator without ever giving it that name. This change
removes the use of that undefined term.
The terms "one's complement" and "two's complement" are well-known,
and it is useful to associate them with these operators.
Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@opensdh, are you ok with this?

@opensdh
Copy link
Contributor

opensdh commented Nov 28, 2022

@opensdh, are you ok with this?

Very much so.

@tkoeppe tkoeppe merged commit bef02b8 into cplusplus:main Dec 15, 2022
@tkoeppe tkoeppe deleted the complnote branch December 15, 2022 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants