Deleted Added
full compact
s_rint.c (175309) s_rint.c (175480)
1/* @(#)s_rint.c 5.1 93/09/24 */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12
13#ifndef lint
1/* @(#)s_rint.c 5.1 93/09/24 */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12
13#ifndef lint
14static char rcsid[] = "$FreeBSD: head/lib/msun/src/s_rint.c 175309 2008-01-14 02:12:07Z das $";
14static char rcsid[] = "$FreeBSD: head/lib/msun/src/s_rint.c 175480 2008-01-19 16:37:57Z bde $";
15#endif
16
17/*
18 * rint(x)
19 * Return x rounded to integral value according to the prevailing
20 * rounding mode.
21 * Method:
22 * Using floating addition.

--- 23 unchanged lines hidden (view full) ---

46 j0 = ((i0>>20)&0x7ff)-0x3ff;
47 if(j0<20) {
48 if(j0<0) {
49 if(((i0&0x7fffffff)|i1)==0) return x;
50 i1 |= (i0&0x0fffff);
51 i0 &= 0xfffe0000;
52 i0 |= ((i1|-i1)>>12)&0x80000;
53 SET_HIGH_WORD(x,i0);
15#endif
16
17/*
18 * rint(x)
19 * Return x rounded to integral value according to the prevailing
20 * rounding mode.
21 * Method:
22 * Using floating addition.

--- 23 unchanged lines hidden (view full) ---

46 j0 = ((i0>>20)&0x7ff)-0x3ff;
47 if(j0<20) {
48 if(j0<0) {
49 if(((i0&0x7fffffff)|i1)==0) return x;
50 i1 |= (i0&0x0fffff);
51 i0 &= 0xfffe0000;
52 i0 |= ((i1|-i1)>>12)&0x80000;
53 SET_HIGH_WORD(x,i0);
54 w = TWO52[sx]+x;
54 STRICT_ASSIGN(double,w,TWO52[sx]+x);
55 t = w-TWO52[sx];
56 GET_HIGH_WORD(i0,t);
57 SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
58 return t;
59 } else {
60 i = (0x000fffff)>>j0;
61 if(((i0&i)|i1)==0) return x; /* x is integral */
62 i>>=1;

--- 16 unchanged lines hidden (view full) ---

79 else return x; /* x is integral */
80 } else {
81 i = ((u_int32_t)(0xffffffff))>>(j0-20);
82 if((i1&i)==0) return x; /* x is integral */
83 i>>=1;
84 if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
85 }
86 INSERT_WORDS(x,i0,i1);
55 t = w-TWO52[sx];
56 GET_HIGH_WORD(i0,t);
57 SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
58 return t;
59 } else {
60 i = (0x000fffff)>>j0;
61 if(((i0&i)|i1)==0) return x; /* x is integral */
62 i>>=1;

--- 16 unchanged lines hidden (view full) ---

79 else return x; /* x is integral */
80 } else {
81 i = ((u_int32_t)(0xffffffff))>>(j0-20);
82 if((i1&i)==0) return x; /* x is integral */
83 i>>=1;
84 if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
85 }
86 INSERT_WORDS(x,i0,i1);
87 *(volatile double *)&w = TWO52[sx]+x; /* clip any extra precision */
87 STRICT_ASSIGN(double,w,TWO52[sx]+x);
88 return w-TWO52[sx];
89}
90
91#if (LDBL_MANT_DIG == 53)
92__weak_reference(rint, rintl);
93#endif
88 return w-TWO52[sx];
89}
90
91#if (LDBL_MANT_DIG == 53)
92__weak_reference(rint, rintl);
93#endif