-
Notifications
You must be signed in to change notification settings - Fork 769
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
[LWG motion 2] P0543R3 Saturation arithmetic #6686
Conversation
source/algorithms.tex
Outdated
|
||
\pnum | ||
\returns | ||
If \tcode{x + y} is representable as a value of type \tcode{T}, \tcode{x + y}; |
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 don't think we want to use code font for the arithmetic operators, as that implies the C++ expression x + y
which is not performed in infinite precision. For unsigned types with width no less than int
the result of x + y
always fits in T
, by definition.
@jensmaurer, the paper doesn't use code font for anything here, not even the type T
. What was the intended presentation for the standard?
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 definitely want the computation to be in the math domain, otherwise "is representable" doesn't make sense.
x and y are parameters, so (individually) need to be monospace, I think.
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 it was fine due to the first paragraph.
But turns out it's a note.
[ Note: In the following descriptions, an arithmetic operation is performed as a mathematical operation with infinite range and then it is determined whether the mathematical result fits into the result type. ]
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.
Can we make the note not be a note? It seems necessary for the understanding of the text. Then, we can spell this as `$\tcode{x} + \tcode{y}$, that'd be close enough I think.
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.
There are other situations where we use math arithmetic and then map back to C++. For example, most prominently, in [expr.pre] p4 to determine when a result is undefined. But, if you feel the note needs to be normative, go for it.
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 think with the formatting changes, we can just about leave it as is. It should perhaps be for LWG to decide whether the specification is sufficiently clear here. @jwakely Should I create an LWG issue for this, or just an informal mail to the reflector maybe?
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.
Just an email is fine, I think.
47d6ace
to
0fe812d
Compare
- Removed trailing 's' from subsection names to match parent. - Modified punctuation for clarity.
This makes the names consistent with std::in_range in <utility>.
0fe812d
to
5604dc2
Compare
We know precisely when saturation happens, so we can say that directly.
5604dc2
to
8f1b3c5
Compare
@jensmaurer, @jwakely: Shall I editorially add |
Sounds right to me. |
Hmm, I'm not sure. Maybe we want |
Fixes #6660.
Fixes cplusplus/papers#1218