number from which to derive a magnitude
number from which to derive a sign
a double-precision floating-point number
var z = copysign( -3.14, 10.0 );
// returns 3.14
var z = copysign( 3.14, -1.0 );
// returns -3.14
var z = copysign( 1.0, -0.0 );
// returns -1.0
var z = copysign( -3.14, -0.0 );
// returns -3.14
var z = copysign( -0.0, 1.0 );
// returns 0.0
Returns a double-precision floating-point number with the magnitude of
x
and the sign ofy
.