10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #if defined(ELFOBJ)
31 #pragma weak nearbyint = __nearbyint
32 #endif
33
34 /*
35 * nearbyint(x) returns the nearest fp integer to x in the direction
36 * corresponding to the current rounding direction without raising
37 * the inexact exception.
38 *
39 * nearbyint(x) is x unchanged if x is +/-0 or +/-inf. If x is NaN,
40 * nearbyint(x) is also NaN.
41 */
42
43 #include "libm.h"
44 #include "fenv_synonyms.h"
45 #include <fenv.h>
46
47 double
48 __nearbyint(double x) {
49 union {
50 unsigned i[2];
51 double d;
52 } xx;
53 unsigned hx, sx, i, frac;
54 int rm, j;
55
56 xx.d = x;
57 sx = xx.i[HIWORD] & 0x80000000;
58 hx = xx.i[HIWORD] & ~0x80000000;
59
60 /* handle trivial cases */
61 if (hx >= 0x43300000) { /* x is nan, inf, or already integral */
62 if (hx >= 0x7ff00000) /* x is inf or nan */
63 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
64 return (hx >= 0x7ff80000 ? x : x + x);
|
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #pragma weak nearbyint = __nearbyint
31
32 /*
33 * nearbyint(x) returns the nearest fp integer to x in the direction
34 * corresponding to the current rounding direction without raising
35 * the inexact exception.
36 *
37 * nearbyint(x) is x unchanged if x is +/-0 or +/-inf. If x is NaN,
38 * nearbyint(x) is also NaN.
39 */
40
41 #include "libm.h"
42 #include <fenv.h>
43
44 double
45 __nearbyint(double x) {
46 union {
47 unsigned i[2];
48 double d;
49 } xx;
50 unsigned hx, sx, i, frac;
51 int rm, j;
52
53 xx.d = x;
54 sx = xx.i[HIWORD] & 0x80000000;
55 hx = xx.i[HIWORD] & ~0x80000000;
56
57 /* handle trivial cases */
58 if (hx >= 0x43300000) { /* x is nan, inf, or already integral */
59 if (hx >= 0x7ff00000) /* x is inf or nan */
60 #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
61 return (hx >= 0x7ff80000 ? x : x + x);
|