Skip to content

core_float_math: Move functions to math module #141282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
806 changes: 417 additions & 389 deletions library/core/src/num/f32.rs

Large diffs are not rendered by default.

794 changes: 411 additions & 383 deletions library/core/src/num/f64.rs

Large diffs are not rendered by default.

142 changes: 71 additions & 71 deletions library/coretests/tests/floats/f32.rs
Original file line number Diff line number Diff line change
@@ -215,88 +215,88 @@ fn test_classify() {

#[test]
fn test_floor() {
assert_approx_eq!(f32::floor(1.0f32), 1.0f32);
assert_approx_eq!(f32::floor(1.3f32), 1.0f32);
assert_approx_eq!(f32::floor(1.5f32), 1.0f32);
assert_approx_eq!(f32::floor(1.7f32), 1.0f32);
assert_approx_eq!(f32::floor(0.0f32), 0.0f32);
assert_approx_eq!(f32::floor(-0.0f32), -0.0f32);
assert_approx_eq!(f32::floor(-1.0f32), -1.0f32);
assert_approx_eq!(f32::floor(-1.3f32), -2.0f32);
assert_approx_eq!(f32::floor(-1.5f32), -2.0f32);
assert_approx_eq!(f32::floor(-1.7f32), -2.0f32);
assert_approx_eq!(f32::math::floor(1.0f32), 1.0f32);
assert_approx_eq!(f32::math::floor(1.3f32), 1.0f32);
assert_approx_eq!(f32::math::floor(1.5f32), 1.0f32);
assert_approx_eq!(f32::math::floor(1.7f32), 1.0f32);
assert_approx_eq!(f32::math::floor(0.0f32), 0.0f32);
assert_approx_eq!(f32::math::floor(-0.0f32), -0.0f32);
assert_approx_eq!(f32::math::floor(-1.0f32), -1.0f32);
assert_approx_eq!(f32::math::floor(-1.3f32), -2.0f32);
assert_approx_eq!(f32::math::floor(-1.5f32), -2.0f32);
assert_approx_eq!(f32::math::floor(-1.7f32), -2.0f32);
}

#[test]
fn test_ceil() {
assert_approx_eq!(f32::ceil(1.0f32), 1.0f32);
assert_approx_eq!(f32::ceil(1.3f32), 2.0f32);
assert_approx_eq!(f32::ceil(1.5f32), 2.0f32);
assert_approx_eq!(f32::ceil(1.7f32), 2.0f32);
assert_approx_eq!(f32::ceil(0.0f32), 0.0f32);
assert_approx_eq!(f32::ceil(-0.0f32), -0.0f32);
assert_approx_eq!(f32::ceil(-1.0f32), -1.0f32);
assert_approx_eq!(f32::ceil(-1.3f32), -1.0f32);
assert_approx_eq!(f32::ceil(-1.5f32), -1.0f32);
assert_approx_eq!(f32::ceil(-1.7f32), -1.0f32);
assert_approx_eq!(f32::math::ceil(1.0f32), 1.0f32);
assert_approx_eq!(f32::math::ceil(1.3f32), 2.0f32);
assert_approx_eq!(f32::math::ceil(1.5f32), 2.0f32);
assert_approx_eq!(f32::math::ceil(1.7f32), 2.0f32);
assert_approx_eq!(f32::math::ceil(0.0f32), 0.0f32);
assert_approx_eq!(f32::math::ceil(-0.0f32), -0.0f32);
assert_approx_eq!(f32::math::ceil(-1.0f32), -1.0f32);
assert_approx_eq!(f32::math::ceil(-1.3f32), -1.0f32);
assert_approx_eq!(f32::math::ceil(-1.5f32), -1.0f32);
assert_approx_eq!(f32::math::ceil(-1.7f32), -1.0f32);
}

#[test]
fn test_round() {
assert_approx_eq!(f32::round(2.5f32), 3.0f32);
assert_approx_eq!(f32::round(1.0f32), 1.0f32);
assert_approx_eq!(f32::round(1.3f32), 1.0f32);
assert_approx_eq!(f32::round(1.5f32), 2.0f32);
assert_approx_eq!(f32::round(1.7f32), 2.0f32);
assert_approx_eq!(f32::round(0.0f32), 0.0f32);
assert_approx_eq!(f32::round(-0.0f32), -0.0f32);
assert_approx_eq!(f32::round(-1.0f32), -1.0f32);
assert_approx_eq!(f32::round(-1.3f32), -1.0f32);
assert_approx_eq!(f32::round(-1.5f32), -2.0f32);
assert_approx_eq!(f32::round(-1.7f32), -2.0f32);
assert_approx_eq!(f32::math::round(2.5f32), 3.0f32);
assert_approx_eq!(f32::math::round(1.0f32), 1.0f32);
assert_approx_eq!(f32::math::round(1.3f32), 1.0f32);
assert_approx_eq!(f32::math::round(1.5f32), 2.0f32);
assert_approx_eq!(f32::math::round(1.7f32), 2.0f32);
assert_approx_eq!(f32::math::round(0.0f32), 0.0f32);
assert_approx_eq!(f32::math::round(-0.0f32), -0.0f32);
assert_approx_eq!(f32::math::round(-1.0f32), -1.0f32);
assert_approx_eq!(f32::math::round(-1.3f32), -1.0f32);
assert_approx_eq!(f32::math::round(-1.5f32), -2.0f32);
assert_approx_eq!(f32::math::round(-1.7f32), -2.0f32);
}

#[test]
fn test_round_ties_even() {
assert_approx_eq!(f32::round_ties_even(2.5f32), 2.0f32);
assert_approx_eq!(f32::round_ties_even(1.0f32), 1.0f32);
assert_approx_eq!(f32::round_ties_even(1.3f32), 1.0f32);
assert_approx_eq!(f32::round_ties_even(1.5f32), 2.0f32);
assert_approx_eq!(f32::round_ties_even(1.7f32), 2.0f32);
assert_approx_eq!(f32::round_ties_even(0.0f32), 0.0f32);
assert_approx_eq!(f32::round_ties_even(-0.0f32), -0.0f32);
assert_approx_eq!(f32::round_ties_even(-1.0f32), -1.0f32);
assert_approx_eq!(f32::round_ties_even(-1.3f32), -1.0f32);
assert_approx_eq!(f32::round_ties_even(-1.5f32), -2.0f32);
assert_approx_eq!(f32::round_ties_even(-1.7f32), -2.0f32);
assert_approx_eq!(f32::math::round_ties_even(2.5f32), 2.0f32);
assert_approx_eq!(f32::math::round_ties_even(1.0f32), 1.0f32);
assert_approx_eq!(f32::math::round_ties_even(1.3f32), 1.0f32);
assert_approx_eq!(f32::math::round_ties_even(1.5f32), 2.0f32);
assert_approx_eq!(f32::math::round_ties_even(1.7f32), 2.0f32);
assert_approx_eq!(f32::math::round_ties_even(0.0f32), 0.0f32);
assert_approx_eq!(f32::math::round_ties_even(-0.0f32), -0.0f32);
assert_approx_eq!(f32::math::round_ties_even(-1.0f32), -1.0f32);
assert_approx_eq!(f32::math::round_ties_even(-1.3f32), -1.0f32);
assert_approx_eq!(f32::math::round_ties_even(-1.5f32), -2.0f32);
assert_approx_eq!(f32::math::round_ties_even(-1.7f32), -2.0f32);
}

#[test]
fn test_trunc() {
assert_approx_eq!(f32::trunc(1.0f32), 1.0f32);
assert_approx_eq!(f32::trunc(1.3f32), 1.0f32);
assert_approx_eq!(f32::trunc(1.5f32), 1.0f32);
assert_approx_eq!(f32::trunc(1.7f32), 1.0f32);
assert_approx_eq!(f32::trunc(0.0f32), 0.0f32);
assert_approx_eq!(f32::trunc(-0.0f32), -0.0f32);
assert_approx_eq!(f32::trunc(-1.0f32), -1.0f32);
assert_approx_eq!(f32::trunc(-1.3f32), -1.0f32);
assert_approx_eq!(f32::trunc(-1.5f32), -1.0f32);
assert_approx_eq!(f32::trunc(-1.7f32), -1.0f32);
assert_approx_eq!(f32::math::trunc(1.0f32), 1.0f32);
assert_approx_eq!(f32::math::trunc(1.3f32), 1.0f32);
assert_approx_eq!(f32::math::trunc(1.5f32), 1.0f32);
assert_approx_eq!(f32::math::trunc(1.7f32), 1.0f32);
assert_approx_eq!(f32::math::trunc(0.0f32), 0.0f32);
assert_approx_eq!(f32::math::trunc(-0.0f32), -0.0f32);
assert_approx_eq!(f32::math::trunc(-1.0f32), -1.0f32);
assert_approx_eq!(f32::math::trunc(-1.3f32), -1.0f32);
assert_approx_eq!(f32::math::trunc(-1.5f32), -1.0f32);
assert_approx_eq!(f32::math::trunc(-1.7f32), -1.0f32);
}

#[test]
fn test_fract() {
assert_approx_eq!(f32::fract(1.0f32), 0.0f32);
assert_approx_eq!(f32::fract(1.3f32), 0.3f32);
assert_approx_eq!(f32::fract(1.5f32), 0.5f32);
assert_approx_eq!(f32::fract(1.7f32), 0.7f32);
assert_approx_eq!(f32::fract(0.0f32), 0.0f32);
assert_approx_eq!(f32::fract(-0.0f32), -0.0f32);
assert_approx_eq!(f32::fract(-1.0f32), -0.0f32);
assert_approx_eq!(f32::fract(-1.3f32), -0.3f32);
assert_approx_eq!(f32::fract(-1.5f32), -0.5f32);
assert_approx_eq!(f32::fract(-1.7f32), -0.7f32);
assert_approx_eq!(f32::math::fract(1.0f32), 0.0f32);
assert_approx_eq!(f32::math::fract(1.3f32), 0.3f32);
assert_approx_eq!(f32::math::fract(1.5f32), 0.5f32);
assert_approx_eq!(f32::math::fract(1.7f32), 0.7f32);
assert_approx_eq!(f32::math::fract(0.0f32), 0.0f32);
assert_approx_eq!(f32::math::fract(-0.0f32), -0.0f32);
assert_approx_eq!(f32::math::fract(-1.0f32), -0.0f32);
assert_approx_eq!(f32::math::fract(-1.3f32), -0.3f32);
assert_approx_eq!(f32::math::fract(-1.5f32), -0.5f32);
assert_approx_eq!(f32::math::fract(-1.7f32), -0.7f32);
}

#[test]
@@ -417,15 +417,15 @@ fn test_mul_add() {
let nan: f32 = f32::NAN;
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
assert_approx_eq!(f32::mul_add(12.3f32, 4.5, 6.7), 62.05);
assert_approx_eq!(f32::mul_add(-12.3f32, -4.5, -6.7), 48.65);
assert_approx_eq!(f32::mul_add(0.0f32, 8.9, 1.2), 1.2);
assert_approx_eq!(f32::mul_add(3.4f32, -0.0, 5.6), 5.6);
assert!(f32::mul_add(nan, 7.8, 9.0).is_nan());
assert_eq!(f32::mul_add(inf, 7.8, 9.0), inf);
assert_eq!(f32::mul_add(neg_inf, 7.8, 9.0), neg_inf);
assert_eq!(f32::mul_add(8.9f32, inf, 3.2), inf);
assert_eq!(f32::mul_add(-3.2f32, 2.4, neg_inf), neg_inf);
assert_approx_eq!(f32::math::mul_add(12.3f32, 4.5, 6.7), 62.05);
assert_approx_eq!(f32::math::mul_add(-12.3f32, -4.5, -6.7), 48.65);
assert_approx_eq!(f32::math::mul_add(0.0f32, 8.9, 1.2), 1.2);
assert_approx_eq!(f32::math::mul_add(3.4f32, -0.0, 5.6), 5.6);
assert!(f32::math::mul_add(nan, 7.8, 9.0).is_nan());
assert_eq!(f32::math::mul_add(inf, 7.8, 9.0), inf);
assert_eq!(f32::math::mul_add(neg_inf, 7.8, 9.0), neg_inf);
assert_eq!(f32::math::mul_add(8.9f32, inf, 3.2), inf);
assert_eq!(f32::math::mul_add(-3.2f32, 2.4, neg_inf), neg_inf);
}

#[test]
129 changes: 65 additions & 64 deletions library/coretests/tests/floats/f64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::f64::consts;
use std::num::FpCategory as Fp;
use core::f64;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, these functions were actually testing the inherent methods on f64, as defined in std, rather than the functions from the f64 module.

Practically, that's the same thing, but the use of UFCS made that not clear.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, mind making the couple of below imports also come from core here rather than std? That would make it match f32.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - that's written (but not yet committed). One thing to note is that these tests do still depend on std, in particular for the powf function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, hopefully we can get that one in soon :)

use core::f64::consts;
use core::num::FpCategory as Fp;

/// Smallest number
const TINY_BITS: u64 = 0x1;
@@ -201,88 +202,88 @@ fn test_classify() {

#[test]
fn test_floor() {
assert_approx_eq!(f64::floor(1.0f64), 1.0f64);
assert_approx_eq!(f64::floor(1.3f64), 1.0f64);
assert_approx_eq!(f64::floor(1.5f64), 1.0f64);
assert_approx_eq!(f64::floor(1.7f64), 1.0f64);
assert_approx_eq!(f64::floor(0.0f64), 0.0f64);
assert_approx_eq!(f64::floor(-0.0f64), -0.0f64);
assert_approx_eq!(f64::floor(-1.0f64), -1.0f64);
assert_approx_eq!(f64::floor(-1.3f64), -2.0f64);
assert_approx_eq!(f64::floor(-1.5f64), -2.0f64);
assert_approx_eq!(f64::floor(-1.7f64), -2.0f64);
assert_approx_eq!(f64::math::floor(1.0f64), 1.0f64);
assert_approx_eq!(f64::math::floor(1.3f64), 1.0f64);
assert_approx_eq!(f64::math::floor(1.5f64), 1.0f64);
assert_approx_eq!(f64::math::floor(1.7f64), 1.0f64);
assert_approx_eq!(f64::math::floor(0.0f64), 0.0f64);
assert_approx_eq!(f64::math::floor(-0.0f64), -0.0f64);
assert_approx_eq!(f64::math::floor(-1.0f64), -1.0f64);
assert_approx_eq!(f64::math::floor(-1.3f64), -2.0f64);
assert_approx_eq!(f64::math::floor(-1.5f64), -2.0f64);
assert_approx_eq!(f64::math::floor(-1.7f64), -2.0f64);
}

#[test]
fn test_ceil() {
assert_approx_eq!(f64::ceil(1.0f64), 1.0f64);
assert_approx_eq!(f64::ceil(1.3f64), 2.0f64);
assert_approx_eq!(f64::ceil(1.5f64), 2.0f64);
assert_approx_eq!(f64::ceil(1.7f64), 2.0f64);
assert_approx_eq!(f64::ceil(0.0f64), 0.0f64);
assert_approx_eq!(f64::ceil(-0.0f64), -0.0f64);
assert_approx_eq!(f64::ceil(-1.0f64), -1.0f64);
assert_approx_eq!(f64::ceil(-1.3f64), -1.0f64);
assert_approx_eq!(f64::ceil(-1.5f64), -1.0f64);
assert_approx_eq!(f64::ceil(-1.7f64), -1.0f64);
assert_approx_eq!(f64::math::ceil(1.0f64), 1.0f64);
assert_approx_eq!(f64::math::ceil(1.3f64), 2.0f64);
assert_approx_eq!(f64::math::ceil(1.5f64), 2.0f64);
assert_approx_eq!(f64::math::ceil(1.7f64), 2.0f64);
assert_approx_eq!(f64::math::ceil(0.0f64), 0.0f64);
assert_approx_eq!(f64::math::ceil(-0.0f64), -0.0f64);
assert_approx_eq!(f64::math::ceil(-1.0f64), -1.0f64);
assert_approx_eq!(f64::math::ceil(-1.3f64), -1.0f64);
assert_approx_eq!(f64::math::ceil(-1.5f64), -1.0f64);
assert_approx_eq!(f64::math::ceil(-1.7f64), -1.0f64);
}

#[test]
fn test_round() {
assert_approx_eq!(f64::round(2.5f64), 3.0f64);
assert_approx_eq!(f64::round(1.0f64), 1.0f64);
assert_approx_eq!(f64::round(1.3f64), 1.0f64);
assert_approx_eq!(f64::round(1.5f64), 2.0f64);
assert_approx_eq!(f64::round(1.7f64), 2.0f64);
assert_approx_eq!(f64::round(0.0f64), 0.0f64);
assert_approx_eq!(f64::round(-0.0f64), -0.0f64);
assert_approx_eq!(f64::round(-1.0f64), -1.0f64);
assert_approx_eq!(f64::round(-1.3f64), -1.0f64);
assert_approx_eq!(f64::round(-1.5f64), -2.0f64);
assert_approx_eq!(f64::round(-1.7f64), -2.0f64);
assert_approx_eq!(f64::math::round(2.5f64), 3.0f64);
assert_approx_eq!(f64::math::round(1.0f64), 1.0f64);
assert_approx_eq!(f64::math::round(1.3f64), 1.0f64);
assert_approx_eq!(f64::math::round(1.5f64), 2.0f64);
assert_approx_eq!(f64::math::round(1.7f64), 2.0f64);
assert_approx_eq!(f64::math::round(0.0f64), 0.0f64);
assert_approx_eq!(f64::math::round(-0.0f64), -0.0f64);
assert_approx_eq!(f64::math::round(-1.0f64), -1.0f64);
assert_approx_eq!(f64::math::round(-1.3f64), -1.0f64);
assert_approx_eq!(f64::math::round(-1.5f64), -2.0f64);
assert_approx_eq!(f64::math::round(-1.7f64), -2.0f64);
}

#[test]
fn test_round_ties_even() {
assert_approx_eq!(f64::round_ties_even(2.5f64), 2.0f64);
assert_approx_eq!(f64::round_ties_even(1.0f64), 1.0f64);
assert_approx_eq!(f64::round_ties_even(1.3f64), 1.0f64);
assert_approx_eq!(f64::round_ties_even(1.5f64), 2.0f64);
assert_approx_eq!(f64::round_ties_even(1.7f64), 2.0f64);
assert_approx_eq!(f64::round_ties_even(0.0f64), 0.0f64);
assert_approx_eq!(f64::round_ties_even(-0.0f64), -0.0f64);
assert_approx_eq!(f64::round_ties_even(-1.0f64), -1.0f64);
assert_approx_eq!(f64::round_ties_even(-1.3f64), -1.0f64);
assert_approx_eq!(f64::round_ties_even(-1.5f64), -2.0f64);
assert_approx_eq!(f64::round_ties_even(-1.7f64), -2.0f64);
assert_approx_eq!(f64::math::round_ties_even(2.5f64), 2.0f64);
assert_approx_eq!(f64::math::round_ties_even(1.0f64), 1.0f64);
assert_approx_eq!(f64::math::round_ties_even(1.3f64), 1.0f64);
assert_approx_eq!(f64::math::round_ties_even(1.5f64), 2.0f64);
assert_approx_eq!(f64::math::round_ties_even(1.7f64), 2.0f64);
assert_approx_eq!(f64::math::round_ties_even(0.0f64), 0.0f64);
assert_approx_eq!(f64::math::round_ties_even(-0.0f64), -0.0f64);
assert_approx_eq!(f64::math::round_ties_even(-1.0f64), -1.0f64);
assert_approx_eq!(f64::math::round_ties_even(-1.3f64), -1.0f64);
assert_approx_eq!(f64::math::round_ties_even(-1.5f64), -2.0f64);
assert_approx_eq!(f64::math::round_ties_even(-1.7f64), -2.0f64);
}

#[test]
fn test_trunc() {
assert_approx_eq!(f64::trunc(1.0f64), 1.0f64);
assert_approx_eq!(f64::trunc(1.3f64), 1.0f64);
assert_approx_eq!(f64::trunc(1.5f64), 1.0f64);
assert_approx_eq!(f64::trunc(1.7f64), 1.0f64);
assert_approx_eq!(f64::trunc(0.0f64), 0.0f64);
assert_approx_eq!(f64::trunc(-0.0f64), -0.0f64);
assert_approx_eq!(f64::trunc(-1.0f64), -1.0f64);
assert_approx_eq!(f64::trunc(-1.3f64), -1.0f64);
assert_approx_eq!(f64::trunc(-1.5f64), -1.0f64);
assert_approx_eq!(f64::trunc(-1.7f64), -1.0f64);
assert_approx_eq!(f64::math::trunc(1.0f64), 1.0f64);
assert_approx_eq!(f64::math::trunc(1.3f64), 1.0f64);
assert_approx_eq!(f64::math::trunc(1.5f64), 1.0f64);
assert_approx_eq!(f64::math::trunc(1.7f64), 1.0f64);
assert_approx_eq!(f64::math::trunc(0.0f64), 0.0f64);
assert_approx_eq!(f64::math::trunc(-0.0f64), -0.0f64);
assert_approx_eq!(f64::math::trunc(-1.0f64), -1.0f64);
assert_approx_eq!(f64::math::trunc(-1.3f64), -1.0f64);
assert_approx_eq!(f64::math::trunc(-1.5f64), -1.0f64);
assert_approx_eq!(f64::math::trunc(-1.7f64), -1.0f64);
}

#[test]
fn test_fract() {
assert_approx_eq!(f64::fract(1.0f64), 0.0f64);
assert_approx_eq!(f64::fract(1.3f64), 0.3f64);
assert_approx_eq!(f64::fract(1.5f64), 0.5f64);
assert_approx_eq!(f64::fract(1.7f64), 0.7f64);
assert_approx_eq!(f64::fract(0.0f64), 0.0f64);
assert_approx_eq!(f64::fract(-0.0f64), -0.0f64);
assert_approx_eq!(f64::fract(-1.0f64), -0.0f64);
assert_approx_eq!(f64::fract(-1.3f64), -0.3f64);
assert_approx_eq!(f64::fract(-1.5f64), -0.5f64);
assert_approx_eq!(f64::fract(-1.7f64), -0.7f64);
assert_approx_eq!(f64::math::fract(1.0f64), 0.0f64);
assert_approx_eq!(f64::math::fract(1.3f64), 0.3f64);
assert_approx_eq!(f64::math::fract(1.5f64), 0.5f64);
assert_approx_eq!(f64::math::fract(1.7f64), 0.7f64);
assert_approx_eq!(f64::math::fract(0.0f64), 0.0f64);
assert_approx_eq!(f64::math::fract(-0.0f64), -0.0f64);
assert_approx_eq!(f64::math::fract(-1.0f64), -0.0f64);
assert_approx_eq!(f64::math::fract(-1.3f64), -0.3f64);
assert_approx_eq!(f64::math::fract(-1.5f64), -0.5f64);
assert_approx_eq!(f64::math::fract(-1.7f64), -0.7f64);
}

#[test]
26 changes: 13 additions & 13 deletions library/std/src/f32.rs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn floor(self) -> f32 {
core::f32::floor(self)
core::f32::math::floor(self)
}

/// Returns the smallest integer greater than or equal to `self`.
@@ -68,7 +68,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn ceil(self) -> f32 {
core::f32::ceil(self)
core::f32::math::ceil(self)
}

/// Returns the nearest integer to `self`. If a value is half-way between two
@@ -96,7 +96,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn round(self) -> f32 {
core::f32::round(self)
core::f32::math::round(self)
}

/// Returns the nearest integer to a number. Rounds half-way cases to the number
@@ -122,7 +122,7 @@ impl f32 {
#[stable(feature = "round_ties_even", since = "1.77.0")]
#[inline]
pub fn round_ties_even(self) -> f32 {
core::f32::round_ties_even(self)
core::f32::math::round_ties_even(self)
}

/// Returns the integer part of `self`.
@@ -147,7 +147,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn trunc(self) -> f32 {
core::f32::trunc(self)
core::f32::math::trunc(self)
}

/// Returns the fractional part of `self`.
@@ -170,7 +170,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn fract(self) -> f32 {
core::f32::fract(self)
core::f32::math::fract(self)
}

/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
@@ -212,7 +212,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn mul_add(self, a: f32, b: f32) -> f32 {
core::f32::mul_add(self, a, b)
core::f32::math::mul_add(self, a, b)
}

/// Calculates Euclidean division, the matching method for `rem_euclid`.
@@ -242,7 +242,7 @@ impl f32 {
#[inline]
#[stable(feature = "euclidean_division", since = "1.38.0")]
pub fn div_euclid(self, rhs: f32) -> f32 {
core::f32::div_euclid(self, rhs)
core::f32::math::div_euclid(self, rhs)
}

/// Calculates the least nonnegative remainder of `self (mod rhs)`.
@@ -279,7 +279,7 @@ impl f32 {
#[inline]
#[stable(feature = "euclidean_division", since = "1.38.0")]
pub fn rem_euclid(self, rhs: f32) -> f32 {
core::f32::rem_euclid(self, rhs)
core::f32::math::rem_euclid(self, rhs)
}

/// Raises a number to an integer power.
@@ -307,7 +307,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn powi(self, n: i32) -> f32 {
core::f32::powi(self, n)
core::f32::math::powi(self, n)
}

/// Raises a number to a floating point power.
@@ -362,7 +362,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn sqrt(self) -> f32 {
core::f32::sqrt(self)
core::f32::math::sqrt(self)
}

/// Returns `e^(self)`, (the exponential function).
@@ -595,7 +595,7 @@ impl f32 {
)]
pub fn abs_sub(self, other: f32) -> f32 {
#[allow(deprecated)]
core::f32::abs_sub(self, other)
core::f32::math::abs_sub(self, other)
}

/// Returns the cube root of a number.
@@ -622,7 +622,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn cbrt(self) -> f32 {
core::f32::cbrt(self)
core::f32::math::cbrt(self)
}

/// Compute the distance between the origin and a point (`x`, `y`) on the
26 changes: 13 additions & 13 deletions library/std/src/f64.rs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn floor(self) -> f64 {
core::f64::floor(self)
core::f64::math::floor(self)
}

/// Returns the smallest integer greater than or equal to `self`.
@@ -68,7 +68,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn ceil(self) -> f64 {
core::f64::ceil(self)
core::f64::math::ceil(self)
}

/// Returns the nearest integer to `self`. If a value is half-way between two
@@ -96,7 +96,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn round(self) -> f64 {
core::f64::round(self)
core::f64::math::round(self)
}

/// Returns the nearest integer to a number. Rounds half-way cases to the number
@@ -122,7 +122,7 @@ impl f64 {
#[stable(feature = "round_ties_even", since = "1.77.0")]
#[inline]
pub fn round_ties_even(self) -> f64 {
core::f64::round_ties_even(self)
core::f64::math::round_ties_even(self)
}

/// Returns the integer part of `self`.
@@ -147,7 +147,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn trunc(self) -> f64 {
core::f64::trunc(self)
core::f64::math::trunc(self)
}

/// Returns the fractional part of `self`.
@@ -170,7 +170,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn fract(self) -> f64 {
core::f64::fract(self)
core::f64::math::fract(self)
}

/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
@@ -212,7 +212,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn mul_add(self, a: f64, b: f64) -> f64 {
core::f64::mul_add(self, a, b)
core::f64::math::mul_add(self, a, b)
}

/// Calculates Euclidean division, the matching method for `rem_euclid`.
@@ -242,7 +242,7 @@ impl f64 {
#[inline]
#[stable(feature = "euclidean_division", since = "1.38.0")]
pub fn div_euclid(self, rhs: f64) -> f64 {
core::f64::div_euclid(self, rhs)
core::f64::math::div_euclid(self, rhs)
}

/// Calculates the least nonnegative remainder of `self (mod rhs)`.
@@ -279,7 +279,7 @@ impl f64 {
#[inline]
#[stable(feature = "euclidean_division", since = "1.38.0")]
pub fn rem_euclid(self, rhs: f64) -> f64 {
core::f64::rem_euclid(self, rhs)
core::f64::math::rem_euclid(self, rhs)
}

/// Raises a number to an integer power.
@@ -307,7 +307,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn powi(self, n: i32) -> f64 {
core::f64::powi(self, n)
core::f64::math::powi(self, n)
}

/// Raises a number to a floating point power.
@@ -362,7 +362,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn sqrt(self) -> f64 {
core::f64::sqrt(self)
core::f64::math::sqrt(self)
}

/// Returns `e^(self)`, (the exponential function).
@@ -595,7 +595,7 @@ impl f64 {
)]
pub fn abs_sub(self, other: f64) -> f64 {
#[allow(deprecated)]
core::f64::abs_sub(self, other)
core::f64::math::abs_sub(self, other)
}

/// Returns the cube root of a number.
@@ -622,7 +622,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn cbrt(self) -> f64 {
core::f64::cbrt(self)
core::f64::math::cbrt(self)
}

/// Compute the distance between the origin and a point (`x`, `y`) on the