File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -645,6 +645,9 @@ impl f128 {
645
645
#[ unstable( feature = "f128" , issue = "116909" ) ]
646
646
#[ must_use = "this returns the result of the operation, without modifying the original" ]
647
647
pub const fn to_degrees ( self ) -> Self {
648
+ // The division here is correctly rounded with respect to the true value of 180/π.
649
+ // Although π is irrational and already rounded, the double rounding happens
650
+ // to produce correct result for f128.
648
651
const PIS_IN_180 : f128 = 180.0 / consts:: PI ;
649
652
self * PIS_IN_180
650
653
}
Original file line number Diff line number Diff line change @@ -872,6 +872,9 @@ impl f32 {
872
872
#[ rustc_const_stable( feature = "const_float_methods" , since = "1.85.0" ) ]
873
873
#[ inline]
874
874
pub const fn to_radians ( self ) -> f32 {
875
+ // The division here is correctly rounded with respect to the true value of π/180.
876
+ // Although π is irrational and already rounded, the double rounding happens
877
+ // to produce correct result for f32.
875
878
const RADS_PER_DEG : f32 = consts:: PI / 180.0 ;
876
879
self * RADS_PER_DEG
877
880
}
Original file line number Diff line number Diff line change @@ -869,9 +869,9 @@ impl f64 {
869
869
#[ rustc_const_stable( feature = "const_float_methods" , since = "1.85.0" ) ]
870
870
#[ inline]
871
871
pub const fn to_degrees ( self ) -> f64 {
872
- // The division here is correctly rounded with respect to the true
873
- // value of 180/π. (This differs from f32, where a constant must be
874
- // used to ensure a correctly rounded result.)
872
+ // The division here is correctly rounded with respect to the true value of 180/π.
873
+ // Although π is irrational and already rounded, the double rounding happens
874
+ // to produce correct result for f64.
875
875
const PIS_IN_180 : f64 = 180.0 / consts:: PI ;
876
876
self * PIS_IN_180
877
877
}
@@ -891,6 +891,9 @@ impl f64 {
891
891
#[ rustc_const_stable( feature = "const_float_methods" , since = "1.85.0" ) ]
892
892
#[ inline]
893
893
pub const fn to_radians ( self ) -> f64 {
894
+ // The division here is correctly rounded with respect to the true value of π/180.
895
+ // Although π is irrational and already rounded, the double rounding happens
896
+ // to produce correct result for f64.
894
897
const RADS_PER_DEG : f64 = consts:: PI / 180.0 ;
895
898
self * RADS_PER_DEG
896
899
}
You can’t perform that action at this time.
0 commit comments