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 it
pub fn abs_sub(self, other: Self) -> Self;
}
More will be added in the future. The blocker for others is the quality of our libm implementations (I am working on improving this).
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
Unresolved Questions
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:More will be added in the future. The blocker for others is the quality of our
libmimplementations (I am working on improving this).For
f32andf64, it isn't easily possible to have the methods unstable incorebut stable instd, 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 instdremoved.Steps / History
coretostdto avoid Clibmdependency Remove dependencies on libm functions from libcore. #27823corefloat types: move copysign, abs, signum to libcore #131304core_float_math#138087core_float_math: Move functions tomathmodule #141282Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩