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
Conversation
@opensdh could you please have a look? |
source/expressions.tex
Outdated
@@ -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. |
There was a problem hiding this comment.
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").
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped!
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
We can keep the notes if you find them useful! |
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.
There was a problem hiding this 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?
Very much so. |
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".