std::copysign

From Cppreference

Jump to: navigation, search
Defined in header <cmath>

float       copysign( float x, float y );
(since C++11)
double      copysign( double x, double y );
(since C++11)
long double copysign( long double x, long double y );
(since C++11)

Composes a floating point value with the magnitude of x and the sign of y.

[edit] Parameters

x, y - floating point values

[edit] Return value

floating point value with the magnitude of x and the sign of y

[edit] See also

absolute value of a floating point value (|x|)
(function)
(C++11)
checks if the given number is negative
(function)