def apply_sign(x, y):
    """Return the absolute value of ``x`` multiplied by
    the sign (i.e., +1 or -1) of ``y``."""
    if y < 0:
        fac = -1.0
    else:
        fac = 1.0
    return abs(x) * fac