xref: /netbsd-src/lib/libm/src/s_fabs.c (revision 07d3f56792e85fbf2ace4137dd5d767b180fea49)
113618394Sjtc /* @(#)s_fabs.c 5.1 93/09/24 */
213618394Sjtc /*
313618394Sjtc  * ====================================================
413618394Sjtc  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
513618394Sjtc  *
613618394Sjtc  * Developed at SunPro, a Sun Microsystems, Inc. business.
713618394Sjtc  * Permission to use, copy, modify, and distribute this
813618394Sjtc  * software is freely granted, provided that this notice
913618394Sjtc  * is preserved.
1013618394Sjtc  * ====================================================
1113618394Sjtc  */
1213618394Sjtc 
1361187201Slukem #include <sys/cdefs.h>
14d1f06e0bSjtc #if defined(LIBM_SCCS) && !defined(lint)
15*07d3f567Sjoerg __RCSID("$NetBSD: s_fabs.c,v 1.11 2013/11/29 22:16:10 joerg Exp $");
16bc3f7bf6Sjtc #endif
17bc3f7bf6Sjtc 
1813618394Sjtc /*
1913618394Sjtc  * fabs(x) returns the absolute value of x.
2013618394Sjtc  */
2113618394Sjtc 
228346e333Sjtc #include "math.h"
238346e333Sjtc #include "math_private.h"
2413618394Sjtc 
25*07d3f567Sjoerg #ifndef __HAVE_LONG_DOUBLE
__strong_alias(fabsl,fabs)26*07d3f567Sjoerg __strong_alias(fabsl, fabs)
27*07d3f567Sjoerg #endif
28*07d3f567Sjoerg 
29aa30599eSwiz double
30aa30599eSwiz fabs(double x)
3113618394Sjtc {
32b0c9d092Sjtc 	u_int32_t high;
338346e333Sjtc 	GET_HIGH_WORD(high,x);
348346e333Sjtc 	SET_HIGH_WORD(x,high&0x7fffffff);
3513618394Sjtc         return x;
3613618394Sjtc }
37