Result is copysign(X, Y)
which should be preferred for portability.
Result is a number of the same type and absolute value as X, but with the sign of Y. Result is therefore either identical to X or to -X.
This function correctly considers the sign bits of special floating point values, such as -0.0, infinities and NaNs.
In coroutining mode, if X or Y is uninstantiated, the predicate delays.
Success:
Result is copysign( 3.0, 2.0). % gives Result = 3.0
Result is copysign( 3.0,-2.0). % gives Result = -3.0
Result is copysign(-3.0, 2.0). % gives Result = 3.0
Result is copysign(-3.0,-2.0). % gives Result = -3.0
Result is copysign( 3.0,-0.0). % gives Result = -3.0
Result is copysign( 3.0, 0.0). % gives Result = 3.0
Result is copysign( 3.0, 0). % gives Result = 3.0
Result is copysign( 3, -1.0). % gives Result = -3
Result is copysign( 1, -0.0). % gives Result = -1
Result is copysign( 3.0, -1). % gives Result = -3.0
Result is copysign(-3.0, 1). % gives Result = 3.0
Error:
Result is copysign(3.0, -0.1__0.1). % arithmetic exception