Skip to content

Commit 3e545bc

Browse files
authored
Rollup merge of rust-lang#125571 - tesuji:dummy-pi, r=Nilstrieb
f32: use constants instead of reassigning a dummy value as PI
2 parents 8409442 + addaaed commit 3e545bc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

core/src/num/f32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ impl f32 {
901901
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
902902
#[inline]
903903
pub fn to_radians(self) -> f32 {
904-
let value: f32 = consts::PI;
905-
self * (value / 180.0f32)
904+
const RADS_PER_DEG: f32 = consts::PI / 180.0;
905+
self * RADS_PER_DEG
906906
}
907907

908908
/// Returns the maximum of the two numbers, ignoring NaN.

core/src/num/f64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,8 @@ impl f64 {
912912
#[stable(feature = "rust1", since = "1.0.0")]
913913
#[inline]
914914
pub fn to_radians(self) -> f64 {
915-
let value: f64 = consts::PI;
916-
self * (value / 180.0)
915+
const RADS_PER_DEG: f64 = consts::PI / 180.0;
916+
self * RADS_PER_DEG
917917
}
918918

919919
/// Returns the maximum of the two numbers, ignoring NaN.

0 commit comments

Comments
 (0)