xref: /minix3/lib/libm/src/s_fabs.c (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
12fe8fb19SBen Gras /* @(#)s_fabs.c 5.1 93/09/24 */
22fe8fb19SBen Gras /*
32fe8fb19SBen Gras  * ====================================================
42fe8fb19SBen Gras  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
52fe8fb19SBen Gras  *
62fe8fb19SBen Gras  * Developed at SunPro, a Sun Microsystems, Inc. business.
72fe8fb19SBen Gras  * Permission to use, copy, modify, and distribute this
82fe8fb19SBen Gras  * software is freely granted, provided that this notice
92fe8fb19SBen Gras  * is preserved.
102fe8fb19SBen Gras  * ====================================================
112fe8fb19SBen Gras  */
122fe8fb19SBen Gras 
132fe8fb19SBen Gras #include <sys/cdefs.h>
142fe8fb19SBen Gras #if defined(LIBM_SCCS) && !defined(lint)
15*84d9c625SLionel Sambuc __RCSID("$NetBSD: s_fabs.c,v 1.11 2013/11/29 22:16:10 joerg Exp $");
162fe8fb19SBen Gras #endif
172fe8fb19SBen Gras 
182fe8fb19SBen Gras /*
192fe8fb19SBen Gras  * fabs(x) returns the absolute value of x.
202fe8fb19SBen Gras  */
212fe8fb19SBen Gras 
222fe8fb19SBen Gras #include "math.h"
232fe8fb19SBen Gras #include "math_private.h"
242fe8fb19SBen Gras 
25*84d9c625SLionel Sambuc #ifndef __HAVE_LONG_DOUBLE
__strong_alias(fabsl,fabs)26*84d9c625SLionel Sambuc __strong_alias(fabsl, fabs)
27*84d9c625SLionel Sambuc #endif
28*84d9c625SLionel Sambuc 
292fe8fb19SBen Gras double
302fe8fb19SBen Gras fabs(double x)
312fe8fb19SBen Gras {
322fe8fb19SBen Gras 	u_int32_t high;
332fe8fb19SBen Gras 	GET_HIGH_WORD(high,x);
342fe8fb19SBen Gras 	SET_HIGH_WORD(x,high&0x7fffffff);
352fe8fb19SBen Gras         return x;
362fe8fb19SBen Gras }
37