@@ -30,6 +30,22 @@ trait TestableFloat: Sized {
3030 const ZERO : Self ;
3131 const ONE : Self ;
3232 const PI : Self ;
33+ const FRAC_PI_2 : Self ;
34+ const FRAC_PI_3 : Self ;
35+ const FRAC_PI_4 : Self ;
36+ const FRAC_PI_6 : Self ;
37+ const FRAC_PI_8 : Self ;
38+ const FRAC_1_PI : Self ;
39+ const FRAC_2_PI : Self ;
40+ const FRAC_2_SQRT_PI : Self ;
41+ const SQRT_2 : Self ;
42+ const FRAC_1_SQRT_2 : Self ;
43+ const E : Self ;
44+ const LOG2_E : Self ;
45+ const LOG10_E : Self ;
46+ const LN_2 : Self ;
47+ const LN_10 : Self ;
48+
3349 const MIN_POSITIVE_NORMAL : Self ;
3450 const MAX_SUBNORMAL : Self ;
3551 /// Smallest number
@@ -78,6 +94,21 @@ impl TestableFloat for f16 {
7894 const ZERO : Self = 0.0 ;
7995 const ONE : Self = 1.0 ;
8096 const PI : Self = std:: f16:: consts:: PI ;
97+ const FRAC_PI_2 : Self = std:: f16:: consts:: FRAC_PI_2 ;
98+ const FRAC_PI_3 : Self = std:: f16:: consts:: FRAC_PI_3 ;
99+ const FRAC_PI_4 : Self = std:: f16:: consts:: FRAC_PI_4 ;
100+ const FRAC_PI_6 : Self = std:: f16:: consts:: FRAC_PI_6 ;
101+ const FRAC_PI_8 : Self = std:: f16:: consts:: FRAC_PI_8 ;
102+ const FRAC_1_PI : Self = std:: f16:: consts:: FRAC_1_PI ;
103+ const FRAC_2_PI : Self = std:: f16:: consts:: FRAC_2_PI ;
104+ const FRAC_2_SQRT_PI : Self = std:: f16:: consts:: FRAC_2_SQRT_PI ;
105+ const SQRT_2 : Self = std:: f16:: consts:: SQRT_2 ;
106+ const FRAC_1_SQRT_2 : Self = std:: f16:: consts:: FRAC_1_SQRT_2 ;
107+ const E : Self = std:: f16:: consts:: E ;
108+ const LOG2_E : Self = std:: f16:: consts:: LOG2_E ;
109+ const LOG10_E : Self = std:: f16:: consts:: LOG10_E ;
110+ const LN_2 : Self = std:: f16:: consts:: LN_2 ;
111+ const LN_10 : Self = std:: f16:: consts:: LN_10 ;
81112 const MIN_POSITIVE_NORMAL : Self = Self :: MIN_POSITIVE ;
82113 const MAX_SUBNORMAL : Self = Self :: MIN_POSITIVE . next_down ( ) ;
83114 const TINY : Self = Self :: from_bits ( 0x1 ) ;
@@ -120,6 +151,21 @@ impl TestableFloat for f32 {
120151 const ZERO : Self = 0.0 ;
121152 const ONE : Self = 1.0 ;
122153 const PI : Self = std:: f32:: consts:: PI ;
154+ const FRAC_PI_2 : Self = std:: f32:: consts:: FRAC_PI_2 ;
155+ const FRAC_PI_3 : Self = std:: f32:: consts:: FRAC_PI_3 ;
156+ const FRAC_PI_4 : Self = std:: f32:: consts:: FRAC_PI_4 ;
157+ const FRAC_PI_6 : Self = std:: f32:: consts:: FRAC_PI_6 ;
158+ const FRAC_PI_8 : Self = std:: f32:: consts:: FRAC_PI_8 ;
159+ const FRAC_1_PI : Self = std:: f32:: consts:: FRAC_1_PI ;
160+ const FRAC_2_PI : Self = std:: f32:: consts:: FRAC_2_PI ;
161+ const FRAC_2_SQRT_PI : Self = std:: f32:: consts:: FRAC_2_SQRT_PI ;
162+ const SQRT_2 : Self = std:: f32:: consts:: SQRT_2 ;
163+ const FRAC_1_SQRT_2 : Self = std:: f32:: consts:: FRAC_1_SQRT_2 ;
164+ const E : Self = std:: f32:: consts:: E ;
165+ const LOG2_E : Self = std:: f32:: consts:: LOG2_E ;
166+ const LOG10_E : Self = std:: f32:: consts:: LOG10_E ;
167+ const LN_2 : Self = std:: f32:: consts:: LN_2 ;
168+ const LN_10 : Self = std:: f32:: consts:: LN_10 ;
123169 const MIN_POSITIVE_NORMAL : Self = Self :: MIN_POSITIVE ;
124170 const MAX_SUBNORMAL : Self = Self :: MIN_POSITIVE . next_down ( ) ;
125171 const TINY : Self = Self :: from_bits ( 0x1 ) ;
@@ -157,6 +203,21 @@ impl TestableFloat for f64 {
157203 const ZERO : Self = 0.0 ;
158204 const ONE : Self = 1.0 ;
159205 const PI : Self = std:: f64:: consts:: PI ;
206+ const FRAC_PI_2 : Self = std:: f64:: consts:: FRAC_PI_2 ;
207+ const FRAC_PI_3 : Self = std:: f64:: consts:: FRAC_PI_3 ;
208+ const FRAC_PI_4 : Self = std:: f64:: consts:: FRAC_PI_4 ;
209+ const FRAC_PI_6 : Self = std:: f64:: consts:: FRAC_PI_6 ;
210+ const FRAC_PI_8 : Self = std:: f64:: consts:: FRAC_PI_8 ;
211+ const FRAC_1_PI : Self = std:: f64:: consts:: FRAC_1_PI ;
212+ const FRAC_2_PI : Self = std:: f64:: consts:: FRAC_2_PI ;
213+ const FRAC_2_SQRT_PI : Self = std:: f64:: consts:: FRAC_2_SQRT_PI ;
214+ const SQRT_2 : Self = std:: f64:: consts:: SQRT_2 ;
215+ const FRAC_1_SQRT_2 : Self = std:: f64:: consts:: FRAC_1_SQRT_2 ;
216+ const E : Self = std:: f64:: consts:: E ;
217+ const LOG2_E : Self = std:: f64:: consts:: LOG2_E ;
218+ const LOG10_E : Self = std:: f64:: consts:: LOG10_E ;
219+ const LN_2 : Self = std:: f64:: consts:: LN_2 ;
220+ const LN_10 : Self = std:: f64:: consts:: LN_10 ;
160221 const MIN_POSITIVE_NORMAL : Self = Self :: MIN_POSITIVE ;
161222 const MAX_SUBNORMAL : Self = Self :: MIN_POSITIVE . next_down ( ) ;
162223 const TINY : Self = Self :: from_bits ( 0x1 ) ;
@@ -194,6 +255,21 @@ impl TestableFloat for f128 {
194255 const ZERO : Self = 0.0 ;
195256 const ONE : Self = 1.0 ;
196257 const PI : Self = std:: f128:: consts:: PI ;
258+ const FRAC_PI_2 : Self = std:: f128:: consts:: FRAC_PI_2 ;
259+ const FRAC_PI_3 : Self = std:: f128:: consts:: FRAC_PI_3 ;
260+ const FRAC_PI_4 : Self = std:: f128:: consts:: FRAC_PI_4 ;
261+ const FRAC_PI_6 : Self = std:: f128:: consts:: FRAC_PI_6 ;
262+ const FRAC_PI_8 : Self = std:: f128:: consts:: FRAC_PI_8 ;
263+ const FRAC_1_PI : Self = std:: f128:: consts:: FRAC_1_PI ;
264+ const FRAC_2_PI : Self = std:: f128:: consts:: FRAC_2_PI ;
265+ const FRAC_2_SQRT_PI : Self = std:: f128:: consts:: FRAC_2_SQRT_PI ;
266+ const SQRT_2 : Self = std:: f128:: consts:: SQRT_2 ;
267+ const FRAC_1_SQRT_2 : Self = std:: f128:: consts:: FRAC_1_SQRT_2 ;
268+ const E : Self = std:: f128:: consts:: E ;
269+ const LOG2_E : Self = std:: f128:: consts:: LOG2_E ;
270+ const LOG10_E : Self = std:: f128:: consts:: LOG10_E ;
271+ const LN_2 : Self = std:: f128:: consts:: LN_2 ;
272+ const LN_10 : Self = std:: f128:: consts:: LN_10 ;
197273 const MIN_POSITIVE_NORMAL : Self = Self :: MIN_POSITIVE ;
198274 const MAX_SUBNORMAL : Self = Self :: MIN_POSITIVE . next_down ( ) ;
199275 const TINY : Self = Self :: from_bits ( 0x1 ) ;
@@ -1521,8 +1597,8 @@ float_test! {
15211597 let inf: Float = Float :: INFINITY ;
15221598 let neg_inf: Float = Float :: NEG_INFINITY ;
15231599 assert_approx_eq!( Float :: ONE . powi( 1 ) , Float :: ONE ) ;
1524- assert_approx_eq!( ( -3.1 as Float ) . powi( 2 ) , 9.6100000000000005506706202140776519387 , Float :: POWI_APPROX ) ;
1525- assert_approx_eq!( ( 5.9 as Float ) . powi( -2 ) , 0.028727377190462507313100483690639638451 ) ;
1600+ assert_approx_eq!( ( -3.1 as Float ) . powi( 2 ) , 9.6100000000000005506706202140776519387 as Float , Float :: POWI_APPROX ) ;
1601+ assert_approx_eq!( ( 5.9 as Float ) . powi( -2 ) , 0.028727377190462507313100483690639638451 as Float ) ;
15261602 assert_biteq!( ( 8.3 as Float ) . powi( 0 ) , Float :: ONE ) ;
15271603 assert!( nan. powi( 2 ) . is_nan( ) ) ;
15281604 assert_biteq!( inf. powi( 3 ) , inf) ;
@@ -1534,18 +1610,18 @@ float_test! {
15341610 name: powf,
15351611 attrs: {
15361612 const : #[ cfg( false ) ] ,
1537- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1613+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
15381614 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
15391615 } ,
15401616 test<Float > {
15411617 let nan: Float = Float :: NAN ;
15421618 let inf: Float = Float :: INFINITY ;
15431619 let neg_inf: Float = Float :: NEG_INFINITY ;
15441620 assert_biteq!( ( 1.0 as Float ) . powf( 1.0 ) , 1.0 ) ;
1545- assert_approx_eq!( ( 3.4 as Float ) . powf( 4.5 ) , 246.40818323761893 , Float :: POWF_APPROX ) ;
1546- assert_approx_eq!( ( 2.7 as Float ) . powf( -3.2 ) , 0.04165200910852618 , Float :: POWF_APPROX ) ;
1547- assert_approx_eq!( ( ( -3.1 ) as Float ) . powf( 2.0 ) , 9.61 , Float :: POWF_APPROX ) ;
1548- assert_approx_eq!( ( 5.9 as Float ) . powf( -2.0 ) , 0.028727377190462507 , Float :: POWF_APPROX ) ;
1621+ assert_approx_eq!( ( 3.4 as Float ) . powf( 4.5 ) , 246.40818323761892815995637964326426756 as Float , Float :: POWF_APPROX ) ;
1622+ assert_approx_eq!( ( 2.7 as Float ) . powf( -3.2 ) , 0.041652009108526178281070304373500889273 as Float , Float :: POWF_APPROX ) ;
1623+ assert_approx_eq!( ( ( -3.1 ) as Float ) . powf( 2.0 ) , 9.6100000000000005506706202140776519387 as Float , Float :: POWF_APPROX ) ;
1624+ assert_approx_eq!( ( 5.9 as Float ) . powf( -2.0 ) , 0.028727377190462507313100483690639638451 as Float , Float :: POWF_APPROX ) ;
15491625 assert_biteq!( ( 8.3 as Float ) . powf( 0.0 ) , 1.0 ) ;
15501626 assert!( nan. powf( 2.0 ) . is_nan( ) ) ;
15511627 assert_biteq!( inf. powf( 2.0 ) , inf) ;
@@ -1557,13 +1633,13 @@ float_test! {
15571633 name: exp,
15581634 attrs: {
15591635 const : #[ cfg( false ) ] ,
1560- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1636+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
15611637 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
15621638 } ,
15631639 test<Float > {
15641640 assert_biteq!( 1.0 , ( 0.0 as Float ) . exp( ) ) ;
15651641 assert_approx_eq!( 2.718281828459045 , ( 1.0 as Float ) . exp( ) , Float :: EXP_APPROX ) ;
1566- assert_approx_eq!( 148.41315910257660342111558004055227962348775 , ( 5.0 as Float ) . exp( ) , Float :: EXP_APPROX ) ;
1642+ assert_approx_eq!( 148.41315910257660342111558004055227962348775 as Float , ( 5.0 as Float ) . exp( ) , Float :: EXP_APPROX ) ;
15671643
15681644 let inf: Float = Float :: INFINITY ;
15691645 let neg_inf: Float = Float :: NEG_INFINITY ;
@@ -1578,7 +1654,7 @@ float_test! {
15781654 name: exp2,
15791655 attrs: {
15801656 const : #[ cfg( false ) ] ,
1581- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1657+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
15821658 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
15831659 } ,
15841660 test<Float > {
@@ -1598,7 +1674,7 @@ float_test! {
15981674 name: ln,
15991675 attrs: {
16001676 const : #[ cfg( false ) ] ,
1601- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1677+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
16021678 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
16031679 } ,
16041680 test<Float > {
@@ -1612,23 +1688,23 @@ float_test! {
16121688 assert!( ( -2.3 as Float ) . ln( ) . is_nan( ) ) ;
16131689 assert_biteq!( ( -0.0 as Float ) . ln( ) , neg_inf) ;
16141690 assert_biteq!( ( 0.0 as Float ) . ln( ) , neg_inf) ;
1615- assert_approx_eq!( ( 4.0 as Float ) . ln( ) , 1.3862943611198906188344642429163531366 , Float :: LN_APPROX ) ;
1691+ assert_approx_eq!( ( 4.0 as Float ) . ln( ) , 1.3862943611198906188344642429163531366 as Float , Float :: LN_APPROX ) ;
16161692 }
16171693}
16181694
16191695float_test ! {
16201696 name: log_generic,
16211697 attrs: {
16221698 const : #[ cfg( false ) ] ,
1623- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1699+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
16241700 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
16251701 } ,
16261702 test<Float > {
16271703 let nan: Float = Float :: NAN ;
16281704 let inf: Float = Float :: INFINITY ;
16291705 let neg_inf: Float = Float :: NEG_INFINITY ;
16301706 assert_biteq!( ( 10.0 as Float ) . log( 10.0 ) , 1.0 ) ;
1631- assert_approx_eq!( ( 2.3 as Float ) . log( 3.5 ) , 0.66485771361478710036766645911922010272 , Float :: LOG_APPROX ) ;
1707+ assert_approx_eq!( ( 2.3 as Float ) . log( 3.5 ) , 0.66485771361478710036766645911922010272 as Float , Float :: LOG_APPROX ) ;
16321708 assert_approx_eq!( ( 1.0 as Float ) . exp( ) . log( ( 1.0 as Float ) . exp( ) ) , 1.0 , Float :: LOG_APPROX ) ;
16331709 assert!( ( 1.0 as Float ) . log( 1.0 ) . is_nan( ) ) ;
16341710 assert!( ( 1.0 as Float ) . log( -13.9 ) . is_nan( ) ) ;
@@ -1645,16 +1721,16 @@ float_test! {
16451721 name: log2,
16461722 attrs: {
16471723 const : #[ cfg( false ) ] ,
1648- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1724+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
16491725 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
16501726 } ,
16511727 test<Float > {
16521728 let nan: Float = Float :: NAN ;
16531729 let inf: Float = Float :: INFINITY ;
16541730 let neg_inf: Float = Float :: NEG_INFINITY ;
1655- assert_approx_eq!( ( 10.0 as Float ) . log2( ) , 3.32192809488736234787031942948939017 , Float :: LOG2_APPROX ) ;
1656- assert_approx_eq!( ( 2.3 as Float ) . log2( ) , 1.2016338611696504130002982471978765921 , Float :: LOG2_APPROX ) ;
1657- assert_approx_eq!( ( 1.0 as Float ) . exp( ) . log2( ) , 1.4426950408889634073599246810018921381 , Float :: LOG2_APPROX ) ;
1731+ assert_approx_eq!( ( 10.0 as Float ) . log2( ) , 3.32192809488736234787031942948939017 as Float , Float :: LOG2_APPROX ) ;
1732+ assert_approx_eq!( ( 2.3 as Float ) . log2( ) , 1.2016338611696504130002982471978765921 as Float , Float :: LOG2_APPROX ) ;
1733+ assert_approx_eq!( ( 1.0 as Float ) . exp( ) . log2( ) , 1.4426950408889634073599246810018921381 as Float , Float :: LOG2_APPROX ) ;
16581734 assert!( nan. log2( ) . is_nan( ) ) ;
16591735 assert_biteq!( inf. log2( ) , inf) ;
16601736 assert!( neg_inf. log2( ) . is_nan( ) ) ;
@@ -1668,16 +1744,16 @@ float_test! {
16681744 name: log10,
16691745 attrs: {
16701746 const : #[ cfg( false ) ] ,
1671- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1747+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
16721748 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
16731749 } ,
16741750 test<Float > {
16751751 let nan: Float = Float :: NAN ;
16761752 let inf: Float = Float :: INFINITY ;
16771753 let neg_inf: Float = Float :: NEG_INFINITY ;
16781754 assert_biteq!( ( 10.0 as Float ) . log10( ) , 1.0 ) ;
1679- assert_approx_eq!( ( 2.3 as Float ) . log10( ) , 0.36172783601759284532595218865859309898 , Float :: LOG10_APPROX ) ;
1680- assert_approx_eq!( ( 1.0 as Float ) . exp( ) . log10( ) , 0.43429448190325182765112891891660508222 , Float :: LOG10_APPROX ) ;
1755+ assert_approx_eq!( ( 2.3 as Float ) . log10( ) , 0.36172783601759284532595218865859309898 as Float , Float :: LOG10_APPROX ) ;
1756+ assert_approx_eq!( ( 1.0 as Float ) . exp( ) . log10( ) , 0.43429448190325182765112891891660508222 as Float , Float :: LOG10_APPROX ) ;
16811757 assert_biteq!( ( 1.0 as Float ) . log10( ) , 0.0 ) ;
16821758 assert!( nan. log10( ) . is_nan( ) ) ;
16831759 assert_biteq!( inf. log10( ) , inf) ;
@@ -1692,7 +1768,7 @@ float_test! {
16921768 name: asinh,
16931769 attrs: {
16941770 const : #[ cfg( false ) ] ,
1695- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1771+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
16961772 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
16971773 } ,
16981774 test<Float > {
@@ -1708,14 +1784,20 @@ float_test! {
17081784 assert!( ( -0.0 as Float ) . asinh( ) . is_sign_negative( ) ) ;
17091785 assert_approx_eq!( ( 2.0 as Float ) . asinh( ) , 1.443635475178810342493276740273105f128 as Float , Float :: ASINH_APPROX ) ;
17101786 assert_approx_eq!( ( -2.0 as Float ) . asinh( ) , -1.443635475178810342493276740273105f128 as Float , Float :: ASINH_APPROX ) ;
1787+
1788+ if Float :: MAX > 66000.0 as Float {
1789+ assert_approx_eq!( ( -67452098.07139316f128 as Float ) . asinh( ) , -18.720075426274544393985484294000831757220 as Float , Float :: ASINH_APPROX ) ;
1790+ } else {
1791+ assert_approx_eq!( ( -200.0 as Float ) . asinh( ) , -5.991470797049389 as Float , Float :: ASINH_APPROX ) ;
1792+ }
17111793 }
17121794}
17131795
17141796float_test ! {
17151797 name: acosh,
17161798 attrs: {
17171799 const : #[ cfg( false ) ] ,
1718- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1800+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
17191801 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
17201802 } ,
17211803 test<Float > {
@@ -1737,7 +1819,7 @@ float_test! {
17371819 name: atanh,
17381820 attrs: {
17391821 const : #[ cfg( false ) ] ,
1740- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1822+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
17411823 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
17421824 } ,
17431825 test<Float > {
@@ -1763,7 +1845,7 @@ float_test! {
17631845 name: gamma,
17641846 attrs: {
17651847 const : #[ cfg( false ) ] ,
1766- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1848+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
17671849 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
17681850 } ,
17691851 test<Float > {
@@ -1788,7 +1870,7 @@ float_test! {
17881870 name: ln_gamma,
17891871 attrs: {
17901872 const : #[ cfg( false ) ] ,
1791- f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math) ) ] ,
1873+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not ( bootstrap_cg_clif ) ) ) ] ,
17921874 f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
17931875 } ,
17941876 test<Float > {
@@ -1815,12 +1897,12 @@ float_test! {
18151897 let inf: Float = Float :: INFINITY ;
18161898 let neg_inf: Float = Float :: NEG_INFINITY ;
18171899 assert_biteq!( ( 0.0 as Float ) . to_degrees( ) , 0.0 ) ;
1818- assert_approx_eq!( ( -5.8 as Float ) . to_degrees( ) , -332.31552117587745090765431723855668471 ) ;
1900+ assert_approx_eq!( ( -5.8 as Float ) . to_degrees( ) , -332.31552117587745090765431723855668471 as Float ) ;
18191901 assert_approx_eq!( pi. to_degrees( ) , 180.0 , Float :: PI_TO_DEGREES_APPROX ) ;
18201902 assert!( nan. to_degrees( ) . is_nan( ) ) ;
18211903 assert_biteq!( inf. to_degrees( ) , inf) ;
18221904 assert_biteq!( neg_inf. to_degrees( ) , neg_inf) ;
1823- assert_biteq!( ( 1.0 as Float ) . to_degrees( ) , 57.2957795130823208767981548141051703 ) ;
1905+ assert_biteq!( ( 1.0 as Float ) . to_degrees( ) , 57.2957795130823208767981548141051703 as Float ) ;
18241906 }
18251907}
18261908
@@ -1836,8 +1918,8 @@ float_test! {
18361918 let inf: Float = Float :: INFINITY ;
18371919 let neg_inf: Float = Float :: NEG_INFINITY ;
18381920 assert_biteq!( ( 0.0 as Float ) . to_radians( ) , 0.0 ) ;
1839- assert_approx_eq!( ( 154.6 as Float ) . to_radians( ) , 2.6982790235832334267135442069489767804 ) ;
1840- assert_approx_eq!( ( -332.31 as Float ) . to_radians( ) , -5.7999036373023566567593094812182763013 ) ;
1921+ assert_approx_eq!( ( 154.6 as Float ) . to_radians( ) , 2.6982790235832334267135442069489767804 as Float ) ;
1922+ assert_approx_eq!( ( -332.31 as Float ) . to_radians( ) , -5.7999036373023566567593094812182763013 as Float ) ;
18411923 assert_approx_eq!( ( 180.0 as Float ) . to_radians( ) , pi, Float :: _180_TO_RADIANS_APPROX) ;
18421924 assert!( nan. to_radians( ) . is_nan( ) ) ;
18431925 assert_biteq!( inf. to_radians( ) , inf) ;
@@ -1920,3 +2002,30 @@ float_test! {
19202002 assert_biteq!( ( flt( -3.2 ) ) . mul_add( 2.4 , neg_inf) , neg_inf) ;
19212003 }
19222004}
2005+
2006+ float_test ! {
2007+ name: real_consts,
2008+ attrs: {
2009+ // FIXME(f16_f128): add math tests when available
2010+ const : #[ cfg( false ) ] ,
2011+ f16: #[ cfg( all( not( miri) , target_has_reliable_f16_math, not( bootstrap_cg_clif) ) ) ] ,
2012+ f128: #[ cfg( all( not( miri) , target_has_reliable_f128_math) ) ] ,
2013+ } ,
2014+ test<Float > {
2015+ let pi: Float = Float :: PI ;
2016+ assert_approx_eq!( Float :: FRAC_PI_2 , pi / 2.0 as Float ) ;
2017+ assert_approx_eq!( Float :: FRAC_PI_3 , pi / 3.0 as Float , Float :: APPROX ) ;
2018+ assert_approx_eq!( Float :: FRAC_PI_4 , pi / 4.0 as Float ) ;
2019+ assert_approx_eq!( Float :: FRAC_PI_6 , pi / 6.0 as Float ) ;
2020+ assert_approx_eq!( Float :: FRAC_PI_8 , pi / 8.0 as Float ) ;
2021+ assert_approx_eq!( Float :: FRAC_1_PI , 1.0 as Float / pi) ;
2022+ assert_approx_eq!( Float :: FRAC_2_PI , 2.0 as Float / pi) ;
2023+ assert_approx_eq!( Float :: FRAC_2_SQRT_PI , 2.0 as Float / pi. sqrt( ) ) ;
2024+ assert_approx_eq!( Float :: SQRT_2 , ( 2.0 as Float ) . sqrt( ) ) ;
2025+ assert_approx_eq!( Float :: FRAC_1_SQRT_2 , 1.0 as Float / ( 2.0 as Float ) . sqrt( ) ) ;
2026+ assert_approx_eq!( Float :: LOG2_E , Float :: E . log2( ) ) ;
2027+ assert_approx_eq!( Float :: LOG10_E , Float :: E . log10( ) ) ;
2028+ assert_approx_eq!( Float :: LN_2 , ( 2.0 as Float ) . ln( ) ) ;
2029+ assert_approx_eq!( Float :: LN_10 , ( 10.0 as Float ) . ln( ) , Float :: APPROX ) ;
2030+ }
2031+ }
0 commit comments