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 and f128
This extends the work done in #130843
Public API
// in `core`
impl <float> {
// ...
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
Unresolved Questions
Footnotes
Feature gate:
#![feature(const_float_round_methods)]This is a tracking issue for making
constsome methods of floating point types:f64::{floor, ceil, trunc, fract, round, round_ties_even}f16,f32andf128This extends the work done in #130843
Public API
Steps / History
constsupport for float rounding methods #141521const_float_round_methods#143604Unresolved Questions
f16andf128be gated behind#[rustc_const_unstable(feature = {"f16", "f128"}, issue = "116909")](from Tracking Issue forf16andf128float types #116909) or#[rustc_const_unstable(feature = "const_float_round_methods", issue = "<this one>")]? The answer is both! Check out this comment: Addconstsupport for float rounding methods #141521 (comment).Footnotes
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩