| OLD | NEW |
| 1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm). | 1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm). |
| 2 // | 2 // |
| 3 // ==================================================== | 3 // ==================================================== |
| 4 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | 4 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
| 5 // | 5 // |
| 6 // Developed at SunSoft, a Sun Microsystems, Inc. business. | 6 // Developed at SunSoft, a Sun Microsystems, Inc. business. |
| 7 // Permission to use, copy, modify, and distribute this | 7 // Permission to use, copy, modify, and distribute this |
| 8 // software is freely granted, provided that this notice | 8 // software is freely granted, provided that this notice |
| 9 // is preserved. | 9 // is preserved. |
| 10 // ==================================================== | 10 // ==================================================== |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 V8_INLINE double __kernel_cos(double x, double y) { | 360 V8_INLINE double __kernel_cos(double x, double y) { |
| 361 static const double | 361 static const double |
| 362 one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ | 362 one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
| 363 C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ | 363 C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ |
| 364 C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ | 364 C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ |
| 365 C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ | 365 C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ |
| 366 C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ | 366 C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ |
| 367 C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ | 367 C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ |
| 368 C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ | 368 C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ |
| 369 | 369 |
| 370 double a, hz, z, r, qx; | 370 double a, iz, z, r, qx; |
| 371 int32_t ix; | 371 int32_t ix; |
| 372 GET_HIGH_WORD(ix, x); | 372 GET_HIGH_WORD(ix, x); |
| 373 ix &= 0x7fffffff; /* ix = |x|'s high word*/ | 373 ix &= 0x7fffffff; /* ix = |x|'s high word*/ |
| 374 if (ix < 0x3e400000) { /* if x < 2**27 */ | 374 if (ix < 0x3e400000) { /* if x < 2**27 */ |
| 375 if (static_cast<int>(x) == 0) return one; /* generate inexact */ | 375 if (static_cast<int>(x) == 0) return one; /* generate inexact */ |
| 376 } | 376 } |
| 377 z = x * x; | 377 z = x * x; |
| 378 r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6))))); | 378 r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6))))); |
| 379 if (ix < 0x3FD33333) { /* if |x| < 0.3 */ | 379 if (ix < 0x3FD33333) { /* if |x| < 0.3 */ |
| 380 return one - (0.5 * z - (z * r - x * y)); | 380 return one - (0.5 * z - (z * r - x * y)); |
| 381 } else { | 381 } else { |
| 382 if (ix > 0x3fe90000) { /* x > 0.78125 */ | 382 if (ix > 0x3fe90000) { /* x > 0.78125 */ |
| 383 qx = 0.28125; | 383 qx = 0.28125; |
| 384 } else { | 384 } else { |
| 385 INSERT_WORDS(qx, ix - 0x00200000, 0); /* x/4 */ | 385 INSERT_WORDS(qx, ix - 0x00200000, 0); /* x/4 */ |
| 386 } | 386 } |
| 387 hz = 0.5 * z - qx; | 387 iz = 0.5 * z - qx; |
| 388 a = one - qx; | 388 a = one - qx; |
| 389 return a - (hz - (z * r - x * y)); | 389 return a - (iz - (z * r - x * y)); |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 /* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) | 393 /* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) |
| 394 * double x[],y[]; int e0,nx,prec; int ipio2[]; | 394 * double x[],y[]; int e0,nx,prec; int ipio2[]; |
| 395 * | 395 * |
| 396 * __kernel_rem_pio2 return the last three digits of N with | 396 * __kernel_rem_pio2 return the last three digits of N with |
| 397 * y = x - N*pi/2 | 397 * y = x - N*pi/2 |
| 398 * so that |y| < pi/2. | 398 * so that |y| < pi/2. |
| 399 * | 399 * |
| (...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 /* argument reduction needed */ | 2304 /* argument reduction needed */ |
| 2305 n = __ieee754_rem_pio2(x, y); | 2305 n = __ieee754_rem_pio2(x, y); |
| 2306 /* 1 -> n even, -1 -> n odd */ | 2306 /* 1 -> n even, -1 -> n odd */ |
| 2307 return __kernel_tan(y[0], y[1], 1 - ((n & 1) << 1)); | 2307 return __kernel_tan(y[0], y[1], 1 - ((n & 1) << 1)); |
| 2308 } | 2308 } |
| 2309 } | 2309 } |
| 2310 | 2310 |
| 2311 } // namespace ieee754 | 2311 } // namespace ieee754 |
| 2312 } // namespace base | 2312 } // namespace base |
| 2313 } // namespace v8 | 2313 } // namespace v8 |
| OLD | NEW |