s_rint.c (3fc5a433e95a01aad0785ed32af6fb2fc2436998) | s_rint.c (d3f9671a7d1d27db78ea3d24b9edaf22e8751b70) |
---|---|
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 --- 10 unchanged lines hidden (view full) --- 19 * Return x rounded to integral value according to the prevailing 20 * rounding mode. 21 * Method: 22 * Using floating addition. 23 * Exception: 24 * Inexact flag raised if x not equal to rint(x). 25 */ 26 | 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 --- 10 unchanged lines hidden (view full) --- 19 * Return x rounded to integral value according to the prevailing 20 * rounding mode. 21 * Method: 22 * Using floating addition. 23 * Exception: 24 * Inexact flag raised if x not equal to rint(x). 25 */ 26 |
27#include <float.h> 28 |
|
27#include "math.h" 28#include "math_private.h" 29 30static const double 31TWO52[2]={ 32 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ 33 -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ 34}; --- 45 unchanged lines hidden (view full) --- 80 if((i1&i)==0) return x; /* x is integral */ 81 i>>=1; 82 if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20)); 83 } 84 INSERT_WORDS(x,i0,i1); 85 *(volatile double *)&w = TWO52[sx]+x; /* clip any extra precision */ 86 return w-TWO52[sx]; 87} | 29#include "math.h" 30#include "math_private.h" 31 32static const double 33TWO52[2]={ 34 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ 35 -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ 36}; --- 45 unchanged lines hidden (view full) --- 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 */ 88 return w-TWO52[sx]; 89} |
90 91#if (LDBL_MANT_DIG == 53) 92__weak_reference(rint, rintl); 93#endif |
|