Open
Description
Feature gate: #![feature(core_float_math)]
This is a tracking issue for floating point math operations in core
.
Public API
The following API will be made available in core
:
impl {f16, f32, f64, f128} {
pub fn floor(self) -> Self;
pub fn ceil(self) -> Self;
pub fn round(self) -> Self;
pub fn round_ties_even(self) -> Self;
pub fn trunc(self) -> Self;
pub fn fract(self) -> Self;
pub fn mul_add(self, a: Self, b: Self) -> Self;
pub fn div_euclid(self, rhs: f128) -> Self;
pub fn rem_euclid(self, rhs: f128) -> Self;
pub fn powi(self, n: i32) -> Self;
pub fn sqrt(self) -> Self;
// Not yet added to f128
pub fn cbrt(self) -> Self;
// Deprecated, but there isn't any reason not to move ti
pub fn abs_sub(self, other: Self) -> Self;
}
More will be added in the future.
For f32
and f64
, it isn't easily possible to have the methods unstable in core
but stable in std
, so standalone functions are used for the feature gate (e.g. core::f32::sqrt
). For stabilization these will be changed to inherent and the duplicates in std
removed.
Steps / History
- Background
- Methods moved from
core
tostd
to avoid Clibm
dependency Remove dependencies on libm functions from libcore. #27823 - Discussion Tracking issue for f32 and f64 methods in libcore #50145
- Discussion Math support in core rfcs#2505
- Trivial methods moved to
core
float types: move copysign, abs, signum to libcore #131304
- Methods moved from
- Implementation: #...
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.