rust-lang / rust-lang/rust

Tracking Issue for `core_float_math`

Open
#137,578 12 comments 39 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

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
Unresolved Questions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the core_float_math feature gate, the listed public API, and the stabilization guide linked in the final comment period. Review the implementation PRs and unresolved issue #142119; done means completing the final comment period and stabilization PR for the tracked API.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.