/**
 * Returns a value with the magnitude of x and the sign of y.
 * NOTE: a port of c++ method from tgmath.h
 * @param {number} x
 * @param {number} y take sign from this value
 * @returns {number}
 */
export function copysign(x, y) {
    if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
        //preserve sign
        return x;
    } else {
        //inverse sign
        return -x;
    }
}