diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 2e715fb0bdd..19fc4489618 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -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. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index db8e1f318ad..34357d1b05a 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -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.