Skip to content

libcore: Rename float constants for consistency. #16370

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
47 changes: 39 additions & 8 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ pub mod consts {
pub static PI: f32 = 3.14159265358979323846264338327950288_f32;

/// pi * 2.0
pub static PI_2: f32 = 6.28318530717958647692528676655900576_f32;
pub static TWO_PI: f32 = 6.28318530717958647692528676655900576_f32;

/// Deprecated: renamed to `TWO_PI`.
#[deprecated = "renamed to TWO_PI"]
pub static PI_2: f32 = TWO_PI;

/// pi/2.0
pub static FRAC_PI_2: f32 = 1.57079632679489661923132169163975144_f32;
Expand All @@ -80,13 +84,25 @@ pub mod consts {
pub static FRAC_2_PI: f32 = 0.636619772367581343075535053490057448_f32;

/// 2.0/sqrt(pi)
pub static FRAC_2_SQRTPI: f32 = 1.12837916709551257389615890312154517_f32;
pub static FRAC_2_SQRT_PI: f32 = 1.12837916709551257389615890312154517_f32;

/// Deprecated: renamed to `FRAC_2_SQRT_PI`.
#[deprecated = "renamed to FRAC_2_SQRT_PI"]
pub static FRAC_2_SQRTPI: f32 = FRAC_2_SQRT_PI;

/// sqrt(2.0)
pub static SQRT2: f32 = 1.41421356237309504880168872420969808_f32;
pub static SQRT_2: f32 = 1.41421356237309504880168872420969808_f32;

/// Deprecated: renamed to `SQRT_2`.
#[deprecated = "renamed to SQRT_2"]
pub static SQRT2: f32 = SQRT_2;

/// 1.0/sqrt(2.0)
pub static FRAC_1_SQRT2: f32 = 0.707106781186547524400844362104849039_f32;
pub static FRAC_1_SQRT_2: f32 = 0.707106781186547524400844362104849039_f32;

/// Deprecated: renamed to `FRAC_1_SQRT_2`.
#[deprecated = "renamed to FRAC_1_SQRT_2"]
pub static FRAC_1_SQRT2: f32 = FRAC_1_SQRT_2;

/// Euler's number
pub static E: f32 = 2.71828182845904523536028747135266250_f32;
Expand Down Expand Up @@ -251,11 +267,21 @@ impl Float for f32 {

/// sqrt(2.0)
#[inline]
fn sqrt2() -> f32 { consts::SQRT2 }
fn sqrt_2() -> f32 { consts::SQRT_2 }

/// Deprecated: renamed to `sqrt_2`.
#[deprecated = "renamed to sqrt_2"]
#[inline]
fn sqrt2() -> f32 { consts::SQRT_2 }

/// 1.0 / sqrt(2.0)
#[inline]
fn frac_1_sqrt2() -> f32 { consts::FRAC_1_SQRT2 }
fn frac_1_sqrt_2() -> f32 { consts::FRAC_1_SQRT_2 }

/// Deprecated: renamed to `frac_1_sqrt_2`.
#[deprecated = "renamed to frac_1_sqrt_2"]
#[inline]
fn frac_1_sqrt2() -> f32 { consts::FRAC_1_SQRT_2 }

#[inline]
fn sqrt(self) -> f32 {
Expand All @@ -271,7 +297,7 @@ impl Float for f32 {

/// 2.0 * pi
#[inline]
fn two_pi() -> f32 { consts::PI_2 }
fn two_pi() -> f32 { consts::TWO_PI }

/// pi / 2.0
#[inline]
Expand Down Expand Up @@ -303,7 +329,12 @@ impl Float for f32 {

/// 2.0 / sqrt(pi)
#[inline]
fn frac_2_sqrtpi() -> f32 { consts::FRAC_2_SQRTPI }
fn frac_2_sqrt_pi() -> f32 { consts::FRAC_2_SQRT_PI }

/// Deprecated: renamed to `frac_2_sqrt_pi`.
#[deprecated = "renamed to frac_2_sqrt_pi"]
#[inline]
fn frac_2_sqrtpi() -> f32 { consts::FRAC_2_SQRT_PI }

/// Euler's number
#[inline]
Expand Down
47 changes: 39 additions & 8 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ pub mod consts {
pub static PI: f64 = 3.14159265358979323846264338327950288_f64;

/// pi * 2.0
pub static PI_2: f64 = 6.28318530717958647692528676655900576_f64;
pub static TWO_PI: f64 = 6.28318530717958647692528676655900576_f64;

/// Deprecated: renamed to `TWO_PI`.
#[deprecated = "renamed to TWO_PI"]
pub static PI_2: f64 = TWO_PI;

/// pi/2.0
pub static FRAC_PI_2: f64 = 1.57079632679489661923132169163975144_f64;
Expand All @@ -86,13 +90,25 @@ pub mod consts {
pub static FRAC_2_PI: f64 = 0.636619772367581343075535053490057448_f64;

/// 2.0/sqrt(pi)
pub static FRAC_2_SQRTPI: f64 = 1.12837916709551257389615890312154517_f64;
pub static FRAC_2_SQRT_PI: f64 = 1.12837916709551257389615890312154517_f64;

/// Deprecated: renamed to `FRAC_2_SQRT_PI`.
#[deprecated = "renamed to FRAC_2_SQRT_PI"]
pub static FRAC_2_SQRTPI: f64 = FRAC_2_SQRT_PI;

/// sqrt(2.0)
pub static SQRT2: f64 = 1.41421356237309504880168872420969808_f64;
pub static SQRT_2: f64 = 1.41421356237309504880168872420969808_f64;

/// Deprecated: renamed to `SQRT_2`.
#[deprecated = "renamed to SQRT_2"]
pub static SQRT2: f64 = SQRT_2;

/// 1.0/sqrt(2.0)
pub static FRAC_1_SQRT2: f64 = 0.707106781186547524400844362104849039_f64;
pub static FRAC_1_SQRT_2: f64 = 0.707106781186547524400844362104849039_f64;

/// Deprecated: renamed to `FRAC_1_SQRT_2`.
#[deprecated = "renamed to FRAC_1_SQRT_2"]
pub static FRAC_1_SQRT2: f64 = FRAC_1_SQRT_2;

/// Euler's number
pub static E: f64 = 2.71828182845904523536028747135266250_f64;
Expand Down Expand Up @@ -258,11 +274,21 @@ impl Float for f64 {

/// sqrt(2.0)
#[inline]
fn sqrt2() -> f64 { consts::SQRT2 }
fn sqrt_2() -> f64 { consts::SQRT_2 }

/// Deprecated: renamed to `sqrt_2`.
#[deprecated = "renamed to sqrt_2"]
#[inline]
fn sqrt2() -> f64 { consts::SQRT_2 }

/// 1.0 / sqrt(2.0)
#[inline]
fn frac_1_sqrt2() -> f64 { consts::FRAC_1_SQRT2 }
fn frac_1_sqrt_2() -> f64 { consts::FRAC_1_SQRT_2 }

/// Deprecated: renamed to `frac_1_sqrt_2`.
#[deprecated = "renamed to frac_1_sqrt_2"]
#[inline]
fn frac_1_sqrt2() -> f64 { consts::FRAC_1_SQRT_2 }

#[inline]
fn sqrt(self) -> f64 {
Expand All @@ -278,7 +304,7 @@ impl Float for f64 {

/// 2.0 * pi
#[inline]
fn two_pi() -> f64 { consts::PI_2 }
fn two_pi() -> f64 { consts::TWO_PI }

/// pi / 2.0
#[inline]
Expand Down Expand Up @@ -310,7 +336,12 @@ impl Float for f64 {

/// 2.0 / sqrt(pi)
#[inline]
fn frac_2_sqrtpi() -> f64 { consts::FRAC_2_SQRTPI }
fn frac_2_sqrt_pi() -> f64 { consts::FRAC_2_SQRT_PI }

/// Deprecated: renamed to `frac_2_sqrt_pi`.
#[deprecated = "renamed to frac_2_sqrt_pi"]
#[inline]
fn frac_2_sqrtpi() -> f64 { consts::FRAC_2_SQRT_PI }

/// Euler's number
#[inline]
Expand Down
12 changes: 11 additions & 1 deletion src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,15 @@ pub trait Float: Signed + Primitive {
fn powf(self, n: Self) -> Self;

/// sqrt(2.0).
fn sqrt2() -> Self;
fn sqrt_2() -> Self;
/// 1.0 / sqrt(2.0).
fn frac_1_sqrt_2() -> Self;

/// Deprecated: renamed to `sqrt_2`.
#[deprecated = "renamed to sqrt_2"]
fn sqrt2() -> Self;
/// Deprecated: renamed to `frac_1_sqrt_2`.
#[deprecated = "renamed to frac_1_sqrt_2"]
fn frac_1_sqrt2() -> Self;

/// Take the square root of a number.
Expand Down Expand Up @@ -1520,6 +1527,9 @@ pub trait Float: Signed + Primitive {
/// 2.0 / pi.
fn frac_2_pi() -> Self;
/// 2.0 / sqrt(pi).
fn frac_2_sqrt_pi() -> Self;
/// Deprecated: renamed to `frac_2_sqrt_pi`.
#[deprecated = "renamed to frac_2_sqrt_pi"]
fn frac_2_sqrtpi() -> Self;

/// Euler's number.
Expand Down