Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

copysign(3) [v7 man page]

COPYSIGN(3)						     Linux Programmer's Manual						       COPYSIGN(3)

copysign, copysignf, copysignl - copy sign of a number SYNOPSIS
#include <math.h> double copysign(double x, double y); float copysignf(float x, float y); long double copysignl(long double x, long double y); Link with -lm. Feature Test Macro Requirements for glibc (see feature_test_macros(7)): copysign(), copysignf(), copysignl(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE DESCRIPTION
These functions return a value whose absolute value matches that of x, but whose sign bit matches that of y. For example, copysign(42.0, -1.0) and copysign(-42.0, -1.0) both return -42.0. RETURN VALUE
On success, these functions return a value whose magnitude is taken from x and whose sign is taken from y. If x is a NaN, a NaN with the sign bit of y is returned. ERRORS
No errors occur. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +-------------------------------------+---------------+---------+ |Interface | Attribute | Value | +-------------------------------------+---------------+---------+ |copysign(), copysignf(), copysignl() | Thread safety | MT-Safe | +-------------------------------------+---------------+---------+ CONFORMING TO
C99, POSIX.1-2001, POSIX.1-2008. This function is defined in IEC 559 (and the appendix with recommended functions in IEEE 754/IEEE 854). NOTES
On architectures where the floating-point formats are not IEEE 754 compliant, these functions may treat a negative zero as positive. SEE ALSO
signbit(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at GNU
2017-09-15 COPYSIGN(3)

Check Out this Related Man Page

ieee_functions(3)					     Library Functions Manual						 ieee_functions(3)

copysign, finite, fp_class, isnan, nextafter, unordered - Related miscellaneous IEEE arithmetic functions. LIBRARY
Math Library (libm.a) SYNOPSIS
#include <math.h> double copysign (double x, double y); float copysignf (float x, float y); long double copysignl (long double x, long double y); int finite (double x); int finitef (float x); int finitel (long double x); int fp_class (double x); int fp_classf (float x); int fp_classl (long double x); int isnan (double x); int isnanf (float x); int isnanl (long double x); double nextafter (double x, double y); float nextafterf (float x, float y); long double nextafterl (long double x, long double y); int unordered (double x, double y); int unorderedf (float x, float y); int unorderedl (long double x, long double y); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: isnan(): XPG4 nextafter(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
The copysign(), copysignf(), and copysignl() functions return x with the same sign as y. IEEE 754 requires copysign(x,NaN), copy- signf(x,NaN) and copysignl(x,NaN) to return +x or -x. The finite(), finitef(), and finitel() functions return the integer value 1 (True) or 0 (False). The finite(x), finitef(x), and finitel(x) functions return 1 when -infinity < x < +infinity. They return 0 when |x| = infinity or x is a NaN. The fp_class(), fp_classf(), and fp_classl() functions determine the class of an IEEE floating-point value. They return one of the con- stants in the file <fp_class.h> and never cause an exception, even for signaling NaNs. These routines implement the recommended function class(x) in the appendix of the IEEE 754-1985 standard for binary floating-point arithmetic. The constants in <fp_class.h> refer to the following classes of values: ----------------------------------------------------- Constant Class ----------------------------------------------------- FP_SNAN Signaling NaN (Not-a-Number) FP_QNAN Quiet NaN (Not-a-Number) FP_POS_INF +infinity FP_NEG_INF -infinity FP_POS_NORM Positive normalized FP_NEG_NORM Negative normalized FP_POS_DENORM Positive denormalized FP_NEG_DENORM Negative denormalized FP_POS_ZERO +0.0 (positive zero) FP_NEG_ZERO -0.0 (negative zero) ----------------------------------------------------- The isnan(), isnanf(), and isnanl() functions return the value 1 (True) if x is NaN (the IEEE floating point reserved not-a-number value); otherwise, it returns the value 0 (False). The nextafter(), nextafterf(), and nextafterl() functions return the next machine-representable number from x in the direction of y. The unordered(), unorderedf(), and unorderedl() functions return the value 1 (True) if either x or y or both is a NaN; otherwise, it returns the value 0 (False). RELATED INFORMATION
drem(3), logb(3), scalb(3), rint(3), sqrt(3), and ANSI/IEEE Std 754-1985, IEEE Standard for Binary Floating-Point Arithmetic delim off ieee_functions(3)
Man Page

Featured Tech Videos