#include
<cmath>
double copysign (double x, double y)
Liefert $|x| \cdot sgn(y)$ mit dem Betrag von x
und dem Vorzeichen von y
.
x , y | Gleitkommazahlen |
Rückgabewert: Zahl mit dem Betrag von x und Vorzeichen von y.
#include <cmath> #include <iostream> int main() { std::cout << std::copysign(3.14, -1) << "\n"; }