File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
library/coretests/tests/floats Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,35 @@ fn test_mul_add() {
4848 assert_biteq ! ( ( -3.2f16 ) . mul_add( 2.4 , neg_inf) , neg_inf) ;
4949}
5050
51+ fn to_radians_expr ( degs : f16 ) -> f16 {
52+ degs * 0.017453292519943295769236907684886_f16
53+ }
54+
55+ fn to_radians_const ( degs : f16 ) -> f16 {
56+ let factor = 0.017453292519943295769236907684886_f16 ;
57+ degs * factor
58+ }
59+
60+ #[ test]
61+ #[ cfg( any( miri, target_has_reliable_f16_math) ) ]
62+ fn expression_has_same_precision_as_constant ( ) {
63+ fn assert_the_same ( val : f16 ) {
64+ assert_biteq ! ( to_radians_expr( val) , to_radians_const( val) ) ;
65+ }
66+ assert_the_same ( -0.0001 ) ;
67+ assert_the_same ( 0.0 ) ;
68+ assert_the_same ( 1.0 ) ;
69+ assert_the_same ( 90.0 ) ;
70+ assert_the_same ( 180.0 ) ;
71+ assert_the_same ( 360.0 ) ;
72+ assert_the_same ( -360.0 ) ;
73+ assert_the_same ( f16:: MAX ) ;
74+ assert_the_same ( f16:: MIN ) ;
75+ assert_the_same ( f16:: NAN ) ;
76+ assert_the_same ( f16:: INFINITY ) ;
77+ assert_the_same ( f16:: NEG_INFINITY ) ;
78+ }
79+
5180#[ test]
5281#[ cfg( any( miri, target_has_reliable_f16_math) ) ]
5382fn test_recip ( ) {
You can’t perform that action at this time.
0 commit comments