1 /* @(#)s_fabs.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 14 static char rcsid[] = "$Id: s_fabs.c,v 1.3 1994/02/18 02:26:27 jtc Exp $"; 15 #endif 16 17 /* 18 * fabs(x) returns the absolute value of x. 19 */ 20 21 #include <math.h> 22 23 #ifdef __STDC__ 24 static const double one = 1.0; 25 #else 26 static double one = 1.0; 27 #endif 28 29 #ifdef __STDC__ 30 double fabs(double x) 31 #else 32 double fabs(x) 33 double x; 34 #endif 35 { 36 *((((*(int*)&one)>>29)^1)+(int*)&x) &= 0x7fffffff; 37 return x; 38 } 39