summaryrefslogtreecommitdiff
path: root/lib/copysignl.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-10-09 15:53:49 +0200
committerBruno Haible <bruno@clisp.org>2011-10-09 16:21:26 +0200
commit28805c10858cd92365be6f74113da8d4939c3dca (patch)
tree0070bc944051771acc05b74872b2c97eb39c1882 /lib/copysignl.c
parent85aa818d44dd0243490d81045c06e6289ab9d43a (diff)
downloadgnulib-28805c10858cd92365be6f74113da8d4939c3dca.tar.gz
New module 'copysignl'.
* lib/math.in.h (copysignl): New declaration. * lib/copysignl.c: New file. * m4/copysignl.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether copysignl is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_COPYSIGNL, HAVE_COPYSIGNL. * modules/math (Makefile.am): Substitute GNULIB_COPYSIGNL, HAVE_COPYSIGNL. * modules/copysignl: New file. * tests/test-math-c++.cc: Check the declaration of copysignl. * modules/math-c++-tests (Makefile.am): Link test-math-c++ against $(COPYSIGNL_LIBM). Needed on IRIX 6.5 with cc. * doc/posix-functions/copysignl.texi: Mention the new module.
Diffstat (limited to 'lib/copysignl.c')
-rw-r--r--lib/copysignl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/copysignl.c b/lib/copysignl.c
new file mode 100644
index 0000000000..95947f464a
--- /dev/null
+++ b/lib/copysignl.c
@@ -0,0 +1,26 @@
+/* Copy sign into another 'long double' number.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <math.h>
+
+long double
+copysignl (long double x, long double y)
+{
+ return (signbit (x) != signbit (y) ? - x : x);
+}