e_rem_pio2.c (176409) | e_rem_pio2.c (176465) |
---|---|
1 2/* @(#)e_rem_pio2.c 1.4 95/01/18 */ 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunSoft, a Sun Microsystems, Inc. business. 8 * Permission to use, copy, modify, and distribute this 9 * software is freely granted, provided that this notice 10 * is preserved. 11 * ==================================================== 12 * 13 */ 14 15#include <sys/cdefs.h> | 1 2/* @(#)e_rem_pio2.c 1.4 95/01/18 */ 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunSoft, a Sun Microsystems, Inc. business. 8 * Permission to use, copy, modify, and distribute this 9 * software is freely granted, provided that this notice 10 * is preserved. 11 * ==================================================== 12 * 13 */ 14 15#include <sys/cdefs.h> |
16__FBSDID("$FreeBSD: head/lib/msun/src/e_rem_pio2.c 176409 2008-02-19 15:30:58Z bde $"); | 16__FBSDID("$FreeBSD: head/lib/msun/src/e_rem_pio2.c 176465 2008-02-22 15:55:14Z bde $"); |
17 18/* __ieee754_rem_pio2(x,y) 19 * 20 * return the remainder of x rem pi/2 in y[0]+y[1] 21 * use __kernel_rem_pio2() 22 */ 23 | 17 18/* __ieee754_rem_pio2(x,y) 19 * 20 * return the remainder of x rem pi/2 in y[0]+y[1] 21 * use __kernel_rem_pio2() 22 */ 23 |
24#include <float.h> 25 |
|
24#include "math.h" 25#include "math_private.h" 26 27static const int32_t npio2_hw[] = { 280x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, 290x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, 300x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, 310x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C, --- 98 unchanged lines hidden (view full) --- 130 y[1] = (z-y[0])+4*pio2_1t; 131 return -4; 132 } 133 } 134 } 135 if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */ 136medium: 137 t = fabs(x); | 26#include "math.h" 27#include "math_private.h" 28 29static const int32_t npio2_hw[] = { 300x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, 310x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, 320x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, 330x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C, --- 98 unchanged lines hidden (view full) --- 132 y[1] = (z-y[0])+4*pio2_1t; 133 return -4; 134 } 135 } 136 } 137 if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */ 138medium: 139 t = fabs(x); |
140#ifdef HAVE_EFFICIENT_IRINT 141 /* Use a specialized rint() to get fn. Assume round-to-nearest. */ 142 STRICT_ASSIGN(double,fn,t*invpio2+0x1.8p52); 143 fn = fn-0x1.8p52; 144 n = irint(fn); 145#else |
|
138 n = (int32_t) (t*invpio2+half); 139 fn = (double)n; | 146 n = (int32_t) (t*invpio2+half); 147 fn = (double)n; |
148#endif |
|
140 r = t-fn*pio2_1; 141 w = fn*pio2_1t; /* 1st round good to 85 bit */ 142 if(n<32&&ix!=npio2_hw[n-1]) { 143 y[0] = r-w; /* quick check no cancellation */ 144 } else { 145 u_int32_t high; 146 j = ix>>20; 147 y[0] = r-w; --- 45 unchanged lines hidden --- | 149 r = t-fn*pio2_1; 150 w = fn*pio2_1t; /* 1st round good to 85 bit */ 151 if(n<32&&ix!=npio2_hw[n-1]) { 152 y[0] = r-w; /* quick check no cancellation */ 153 } else { 154 u_int32_t high; 155 j = ix>>20; 156 y[0] = r-w; --- 45 unchanged lines hidden --- |