Skip to content

Tracking Issue for core_float_math #137578

Open
@tgross35

Description

@tgross35

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

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions