Open
Description
opened on Apr 26, 2023
Feature gate: #[feature(num_midpoint)]
, #[feature(num_midpoint_signed)]
and #![feature(const_num_midpoint)]
This is a tracking issue for the midpoint function to {u,i}{8,16,32,64,128,size}
, NonZeroU{8,16,32,64,size}
and f{32,64}
.
The midpoint function calculates the middle point of lhs
and rhs
.
Public API
impl {u,i}{8,16,32,64,128,size} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
impl NonZeroU{8,16,32,64,size} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
impl f{32,64} {
pub const fn midpoint(self, rhs: Self) -> Self;
}
Steps / History
- Implementation: Add midpoint function for all integers and floating numbers #92048
- Final comment period (FCP)1
- For unsigned and floats variants Stabilize unsigned and float variants of
num_midpoint
feature #131784 (comment) - For signed variants Stabilize
num_midpoint_signed
feature #134340
- For unsigned and floats variants Stabilize unsigned and float variants of
- Stabilization PR
- For unsigned and floats variants Stabilize unsigned and float variants of
num_midpoint
feature #131784 - For signed variants Stabilize
num_midpoint_signed
feature #134340
- For unsigned and floats variants Stabilize unsigned and float variants of
Unresolved Questions
- Rounding of negative signed integer (current behavior is round towards
negative infinityzero): Add midpoint function for all integers and floating numbers #92048 (comment)- As of Round negative signed integer towards zero in
iN::midpoint
#132191 we round towards zero, as to be consistent with the obvious impl(a + b) / 2
.
- As of Round negative signed integer towards zero in
Whether it's commutative (some people wantmidpoint(a, b) == midpoint(b, a)
, but others want a non-commutative definition)- The (unsigned) FCP proposed that it be commutative and that was accepted.
Activity