summaryrefslogtreecommitdiff
path: root/lib/msun/src/s_fabs.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/msun/src/s_fabs.c')
-rw-r--r--lib/msun/src/s_fabs.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/msun/src/s_fabs.c b/lib/msun/src/s_fabs.c
new file mode 100644
index 000000000000..7cf1ccae8b28
--- /dev/null
+++ b/lib/msun/src/s_fabs.c
@@ -0,0 +1,38 @@
+/* @(#)s_fabs.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$Id: s_fabs.c,v 1.1.1.1 1994/05/06 00:20:04 gclarkii Exp $";
+#endif
+
+/*
+ * fabs(x) returns the absolute value of x.
+ */
+
+#include "math.h"
+
+#ifdef __STDC__
+static const double one = 1.0;
+#else
+static double one = 1.0;
+#endif
+
+#ifdef __STDC__
+ double fabs(double x)
+#else
+ double fabs(x)
+ double x;
+#endif
+{
+ *((((*(int*)&one)>>29)^1)+(int*)&x) &= 0x7fffffff;
+ return x;
+}