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

[LWG motion 2] P0543R3 Saturation arithmetic #6686

Merged
merged 3 commits into from Dec 17, 2023
Merged

Conversation

burblebee
Copy link
Contributor

@burblebee burblebee commented Nov 14, 2023

  • Removed trailing 's' from subsection names to match parent.
  • Modified punctuation for clarity.

Fixes #6660.
Fixes cplusplus/papers#1218

@burblebee burblebee marked this pull request as ready for review November 14, 2023 19:54
@jensmaurer jensmaurer added this to the post-2023-11 milestone Nov 15, 2023
source/algorithms.tex Outdated Show resolved Hide resolved

\pnum
\returns
If \tcode{x + y} is representable as a value of type \tcode{T}, \tcode{x + y};
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor

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. ]

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Member

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.

source/algorithms.tex Outdated Show resolved Hide resolved
source/algorithms.tex Outdated Show resolved Hide resolved
@tkoeppe tkoeppe force-pushed the motions-2023-11-lwg-2 branch 2 times, most recently from 47d6ace to 0fe812d Compare December 17, 2023 03:16
burblebee and others added 2 commits December 17, 2023 12:35
- Removed trailing 's' from subsection names to match parent.
- Modified punctuation for clarity.
This makes the names consistent with std::in_range in <utility>.
We know precisely when saturation happens, so we can say that directly.
@tkoeppe tkoeppe merged commit 24c4b48 into main Dec 17, 2023
4 checks passed
@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 17, 2023

@jensmaurer, @jwakely: Shall I editorially add <numeric> to the "also in" feature test macro cpp_lib_freestanding_algorithm introduced by Motion 3?

@jensmaurer
Copy link
Member

Sounds right to me.

@jwakely
Copy link
Member

jwakely commented Dec 17, 2023

@jensmaurer, @jwakely: Shall I editorially add <numeric> to the "also in" feature test macro cpp_lib_freestanding_algorithm introduced by Motion 3?

Hmm, I'm not sure. Maybe we want __cpp_lib_freestanding_numeric for these instead.

@jensmaurer jensmaurer deleted the motions-2023-11-lwg-2 branch March 23, 2024 11:45
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.

[2023-11 LWG Motion 2] Saturation arithmetic P0543 R3 Saturation arithmetic
6 participants