-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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 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
- Background
- Methods moved from
coretostdto avoid Clibmdependency 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
corefloat types: move copysign, abs, signum to libcore #131304
- Methods moved from
- Implementation:
- Initial implementation Initial implementation of
core_float_math#138087 - Functions moved to a module
core_float_math: Move functions tomathmodule #141282
- Initial implementation Initial implementation of
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.
Footnotes
jokeyrhyme, DianaNites, michael-p, madsmtm, Kobzol and 10 morebjoernager, amrali, jonatino and Robbepop
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.