Stabilize unsigned and float variants of num_midpoint feature - #131784
Conversation
|
@rfcbot fcp merge |
|
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
This absolutely is 👍 from me. (Thanks for the ping!) I'm a fan of it as described here where it's consistent with That said, I feel obliged to mention that in the tracking issue that some people want |
|
Actually, @Urgau , consider putting "and float" in the title & OP here. To me the "stabilize the unsigned variants" text wouldn't include floats, since they're obviously signed. |
num_midpoint featurenum_midpoint feature
num_midpoint featurenum_midpoint feature
|
Float |
388f953 to
1345744
Compare
Good point, updated the PR to include the const stabilization of |
I would advocate the behavior that |
…r=dtolnay Round negative signed integer towards zero in `iN::midpoint` This PR changes the implementation of `iN::midpoint` (the signed variants) to round negative signed integers **towards zero** *instead* of negative infinity as is currently the case. This is done so that the obvious expectations[^1] of `midpoint(a, b) == midpoint(b, a)` and `midpoint(-a, -b) == -midpoint(a, b)` are true, which makes the even more obvious implementation `(a + b) / 2` always true. The unsigned variants `uN::midpoint` (which are being [FCP-ed](rust-lang#131784 (comment))) already rounds towards zero, so there is no consistency issue. cc `@scottmcm` r? `@dtolnay` [^1]: rust-lang#110840 (comment)
This comment was marked as resolved.
This comment was marked as resolved.
70e5e08 to
e217d60
Compare
cf3aa1d to
b88478f
Compare
|
@bors r=dtolnay |
This PR proposes that we stabilize the unsigned variants of the
num_midpointfeature as well as the floats variants, since they are not subject to any unresolved questions, which is equivalent to doing(a + b) / 2(and(a + b) >> 1) in a sufficiently large number.The stabilized API surface would be:
The signed variants
u{8,16,32,64,128,size}would remain gated, until a decision is made about the rounding mode, in other words that the unresolved questions are resolved.cc @rust-lang/libs-api
cc @scottmcm
r? libs-api