logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

copysign, copysignf, copysignl - copy sign of a number

Attributes

       For an explanation of the terms used in this section, see attributes(7).
       ┌─────────────────────────────────────────────────────────────────────────────┬───────────────┬─────────┐
       │ InterfaceAttributeValue   │
       ├─────────────────────────────────────────────────────────────────────────────┼───────────────┼─────────┤
       │ copysign(), copysignf(), copysignl()                                        │ Thread safety │ MT-Safe │
       └─────────────────────────────────────────────────────────────────────────────┴───────────────┴─────────┘

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.

Errors

       No errors occur.

History

       C99, POSIX.1-2001, 4.3BSD.

Library

       Math library (libm, -lm)

Name

       copysign, copysignf, copysignl - copy sign of a number

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.

See Also

signbit(3)

Linux man-pages 6.9.1                              2024-05-02                                        copysign(3)

Standards

       C11, POSIX.1-2008.

       This function is defined in IEC 559 (and the appendix with recommended functions in IEEE 754/IEEE 854).

Synopsis

#include<math.h>doublecopysign(doublex,doubley);floatcopysignf(floatx,floaty);longdoublecopysignl(longdoublex,longdoubley);

   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 <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

Versions

       On architectures where the floating-point formats are not IEEE 754 compliant, these functions may treat a
       negative zero as positive.

See Also