Skip to content

Commit 8ebaf63

Browse files
committed
simplify f16 to_degrees and to_radians by using expression directly
1 parent c018ae5 commit 8ebaf63

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

library/core/src/num/f16.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,7 @@ impl f16 {
640640
#[unstable(feature = "f16", issue = "116909")]
641641
#[must_use = "this returns the result of the operation, without modifying the original"]
642642
pub const fn to_degrees(self) -> Self {
643-
// Use a literal for better precision.
644-
const PIS_IN_180: f16 = 57.2957795130823208767981548141051703_f16;
645-
self * PIS_IN_180
643+
self * 57.2957795130823208767981548141051703_f16
646644
}
647645

648646
/// Converts degrees to radians.
@@ -663,9 +661,7 @@ impl f16 {
663661
#[unstable(feature = "f16", issue = "116909")]
664662
#[must_use = "this returns the result of the operation, without modifying the original"]
665663
pub const fn to_radians(self) -> f16 {
666-
// Use a literal for better precision.
667-
const RADS_PER_DEG: f16 = 0.017453292519943295769236907684886_f16;
668-
self * RADS_PER_DEG
664+
self * 0.017453292519943295769236907684886_f16
669665
}
670666

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

0 commit comments

Comments
 (0)