Tracking Issue for #![feature(const_float_round_methods)]
· Issue #141555 · rust-lang/rust (original) (raw)
Feature gate: #![feature(const_float_round_methods)]
This is a tracking issue for making const
some methods of floating point types:
f64::{floor, ceil, trunc, fract, round, round_ties_even}
- and the corresponding methods for
f16
,f32
andf128
This extends the work done in #130843
Public API
// in core
impl {
// ...
pub const fn floor(self) -> Self;
pub const fn ceil(self) -> Self;
pub const fn trunc(self) -> Self;
pub const fn fract(self) -> Self;
pub const fn round(self) -> Self;
pub const fn round_ties_even(self) -> Self;
// ...
}
Steps / History
- Opened a discussion topic on the internals forum: Const rounding methods in float types
- Since all the required machinery was already implemented in the Miri, the implementation was straightforward.
- Implementation: Add const support for float rounding methods #141521
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Should the rounding methods on
f16
andf128
be gated behind#[rustcconstunstable(feature = {"f16", "f128"}, issue = "116909")]
(from Tracking Issue for f16 and f128 float types #116909) or#[rustcconstunstable(feature = "constfloatroundmethods", issue = "<this one>")]
? The answer is both! Check out this comment: Add const support for float rounding methods #141521 (comment).