src/libm/k_rem_pio2.c
changeset 8670 0c15c8a2f8c3
parent 6044 35448a5ea044
child 10650 b6ec7005ca15
equal deleted inserted replaced
8669:62dfa45e5e08 8670:0c15c8a2f8c3
   131  * to produce the hexadecimal values shown.
   131  * to produce the hexadecimal values shown.
   132  */
   132  */
   133 
   133 
   134 #include "math_libm.h"
   134 #include "math_libm.h"
   135 #include "math_private.h"
   135 #include "math_private.h"
       
   136 
       
   137 #include "SDL_assert.h"
   136 
   138 
   137 libm_hidden_proto(scalbn)
   139 libm_hidden_proto(scalbn)
   138     libm_hidden_proto(floor)
   140     libm_hidden_proto(floor)
   139 #ifdef __STDC__
   141 #ifdef __STDC__
   140      static const int init_jk[] = { 2, 3, 4, 6 };       /* initial value for jk */
   142      static const int init_jk[] = { 2, 3, 4, 6 };       /* initial value for jk */
   179 {
   181 {
   180     int32_t jz, jx, jv, jp, jk, carry, n, iq[20], i, j, k, m, q0, ih;
   182     int32_t jz, jx, jv, jp, jk, carry, n, iq[20], i, j, k, m, q0, ih;
   181     double z, fw, f[20], fq[20], q[20];
   183     double z, fw, f[20], fq[20], q[20];
   182 
   184 
   183     /* initialize jk */
   185     /* initialize jk */
       
   186     SDL_assert((prec >= 0) && (prec < SDL_arraysize(init_jk)));
   184     jk = init_jk[prec];
   187     jk = init_jk[prec];
       
   188     SDL_assert((jk >= 2) && (jk <= 6));
   185     jp = jk;
   189     jp = jk;
   186 
   190 
   187     /* determine jx,jv,q0, note that 3>q0 */
   191     /* determine jx,jv,q0, note that 3>q0 */
       
   192     SDL_assert(nx > 0);
   188     jx = nx - 1;
   193     jx = nx - 1;
   189     jv = (e0 - 3) / 24;
   194     jv = (e0 - 3) / 24;
   190     if (jv < 0)
   195     if (jv < 0)
   191         jv = 0;
   196         jv = 0;
   192     q0 = e0 - 24 * (jv + 1);
   197     q0 = e0 - 24 * (jv + 1);