Rollup merge of #125571 - tesuji:dummy-pi, r=Nilstrieb

f32: use constants instead of reassigning a dummy value as PI
This commit is contained in:
Matthias Krüger 2024-05-26 13:43:08 +02:00 committed by GitHub
commit 27cdb36ec5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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.

View File

@ -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.