Skip to content

Commit

Permalink
Rollup merge of rust-lang#125571 - tesuji:dummy-pi, r=Nilstrieb
Browse files Browse the repository at this point in the history
f32: use constants instead of reassigning a dummy value as PI
  • Loading branch information
matthiaskrgr authored May 26, 2024
2 parents 8409442 + addaaed commit 3e545bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ impl f32 {
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
#[inline]
pub fn to_radians(self) -> f32 {
let value: f32 = consts::PI;
self * (value / 180.0f32)
const RADS_PER_DEG: f32 = consts::PI / 180.0;
self * RADS_PER_DEG
}

/// Returns the maximum of the two numbers, ignoring NaN.
Expand Down
4 changes: 2 additions & 2 deletions core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn to_radians(self) -> f64 {
let value: f64 = consts::PI;
self * (value / 180.0)
const RADS_PER_DEG: f64 = consts::PI / 180.0;
self * RADS_PER_DEG
}

/// Returns the maximum of the two numbers, ignoring NaN.
Expand Down

0 comments on commit 3e545bc

Please sign in to comment.