From addaaed02ce43b0c870215158af8d5adeda613ab Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 26 May 2024 09:32:39 +0000 Subject: [PATCH] f32: use constants instead of reassigning a dummy value as PI --- core/src/num/f32.rs | 4 ++-- core/src/num/f64.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/num/f32.rs b/core/src/num/f32.rs index 2e715fb0bdde7..19fc4489618ff 100644 --- a/core/src/num/f32.rs +++ b/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/core/src/num/f64.rs b/core/src/num/f64.rs index db8e1f318adba..34357d1b05ad5 100644 --- a/core/src/num/f64.rs +++ b/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.