@@ -4,14 +4,21 @@ use core::f64::consts;
44
55use crate :: support:: { CastFrom , CastInto , DInt , Float , HInt , HalfRep , Int , MinInt } ;
66
7- pub ( crate ) trait RemFracPi2Support : Float < Int : DInt < H : Int > > {
7+ pub ( crate ) trait RemPio2Support : Float < Int : DInt < H : Int > > {
88 const TO_INT : Self ;
9+ /// 53 bits of 2/pi
910 const INV_PIO2 : Self ;
11+ /// first 33 bits of pi/2
1012 const PIO2_1 : Self ;
13+ /// pi/2 - PIO2_1
1114 const PIO2_1T : Self ;
15+ /// second 33 bits of pi/2
1216 const PIO2_2 : Self ;
17+ /// pi/2 - (PIO2_1+PIO2_2)
1318 const PIO2_2T : Self ;
19+ /// third 33 bits of pi/2
1420 const PIO2_3 : Self ;
21+ /// pi/2 - (PIO2_1+PIO2_2+PIO2_3)
1522 const PIO2_3T : Self ;
1623
1724 const FRAC_5PI_4_HI : HalfRep < Self > ;
@@ -31,42 +38,12 @@ pub(crate) trait RemFracPi2Support: Float<Int: DInt<H: Int>> {
3138 fn large ( x : & [ Self ] , y : & mut [ Self ] , e0 : i32 , prec : usize ) -> i32 ;
3239}
3340
34- const EPS : f64 = 2.2204460492503131e-16 ;
35-
36- impl RemFracPi2Support for f64 {
37- const TO_INT : Self = 1.5 / EPS ;
38- const INV_PIO2 : Self = 6.36619772367581382433e-01 ;
39- const PIO2_1 : Self = 1.57079632673412561417e+00 ;
40- const PIO2_1T : Self = 6.07710050650619224932e-11 ;
41- const PIO2_2 : Self = 6.07710050630396597660e-11 ;
42- const PIO2_2T : Self = 2.02226624879595063154e-21 ;
43- const PIO2_3 : Self = 2.02226624871116645580e-21 ;
44- const PIO2_3T : Self = 8.47842766036889956997e-32 ;
45- const FRAC_5PI_4_HI : HalfRep < Self > = 0x400f6a7a ;
46- const FRAC_3PI_4_HI : HalfRep < Self > = 0x4002d97c ;
47- const FRAC_9PI_4_HI : HalfRep < Self > = 0x401c463b ;
48- const FRAC_7PI_4_HI : HalfRep < Self > = 0x4015fdbc ;
49- const FRAC_3PI_2_HI : HalfRep < Self > = 0x4012d97c ;
50- const TAU_HI : HalfRep < Self > = 0x401921fb ;
51- const FRAC_PI_2_HI : HalfRep < Self > = 0x921fb ;
52- const FRAC_2_POW_20_PI_2 : HalfRep < Self > = 0x413921fb ;
53-
54- const MAGIC_F : Self = hf64 ! ( "0x1p24" ) ;
55-
56- fn large ( x : & [ Self ] , y : & mut [ Self ] , e0 : i32 , prec : usize ) -> i32 {
57- super :: super :: rem_pio2_large ( x, y, e0, prec)
58- }
59- }
60-
61- pub ( crate ) fn rem_frac_pi_2 < F > ( x : F ) -> ( i32 , F , F )
41+ pub ( crate ) fn rem_pio2 < F > ( x : F ) -> ( i32 , F , F )
6242where
63- F : RemFracPi2Support ,
43+ F : RemPio2Support ,
6444 F : CastInto < i32 > ,
6545 HalfRep < F > : Int + MinInt < Unsigned : Int < OtherSign : Int > > ,
66- // <HalfRep<F> as Int>::Unsigned: Int,
6746{
68- // let sign = x.is_sign_positive()
69-
7047 let ix: HalfRep < F > = x. abs ( ) . to_bits ( ) . hi ( ) ;
7148 let pos = x. is_sign_positive ( ) ;
7249
@@ -148,9 +125,8 @@ where
148125 return medium ( x, ix) ;
149126 }
150127 /*
151-
152- * all other (large) arguments
153- */
128+ * all other (large) arguments
129+ */
154130 if ix >= F :: EXP_MASK . hi ( ) {
155131 /* x is inf or NaN */
156132 let y0 = x - x;
@@ -161,7 +137,6 @@ where
161137 /* set z = scalbn(|x|,-ilogb(x)+23) */
162138 let mut ui = x. to_bits ( ) ;
163139 ui &= F :: SIG_MASK ;
164- // ui |= F::Int::cast_from((F::EXP_BIAS + F::MAGIC) << F::SIG_BITS);
165140 ui |= F :: Int :: cast_from ( F :: EXP_BIAS + F :: MAGIC ) << F :: SIG_BITS ;
166141
167142 let mut z = F :: from_bits ( ui) ;
@@ -195,7 +170,7 @@ where
195170
196171pub fn medium < F > ( x : F , ix : HalfRep < F > ) -> ( i32 , F , F )
197172where
198- F : RemFracPi2Support ,
173+ F : RemPio2Support ,
199174 F : CastInto < i32 > ,
200175 HalfRep < F > : Int ,
201176{
0 commit comments