Return the sign of x.

    Return a positive integer if x > 0, 0 if x == 0, and a negative integer if
    x < 0.  Raise ValueError if x is a NaN.

    This function is equivalent to cmp(x, 0), but more efficient.

def sgn(x):
    """
    Return the sign of x.

    Return a positive integer if x > 0, 0 if x == 0, and a negative integer if
    x < 0.  Raise ValueError if x is a NaN.

    This function is equivalent to cmp(x, 0), but more efficient.

    """
    x = BigFloat._implicit_convert(x)
    if is_nan(x):
        raise ValueError("Cannot take sign of a NaN.")
    return mpfr.mpfr_sgn(x)