def METHOD_NAME(self, x: float, max_prec: int = 2**13) -> float:
    if math.isnan(x):
        return math.nan  # skip computation
    elif math.isinf(x):
        return x
    prec = mp.prec
    cdf = self.cdf
    p = cdf(mpmathify(x))
    use_complement = mp.almosteq(p, mpf("1"))
    # it required many more bits to represent a number close to one than a
    # number close to zero
    if use_complement:
        cdf = self.cdfc
    z = math.nan
    try:
        # infer base precision
        while mp.prec < max_prec:
            p = cdf(mpmathify(x))
            if not mp.almosteq(p, mpf("1")) and not mp.almosteq(p, mpf("0")):
                # we have sufficient precision to represent the p-value
                calc_z = autoprec(lambda: normppf(cdf(mpmathify(x))))
                z = float(calc_z())
                break
            if mp.prec <= 2**12:
                mp.prec += 2**8
            else:
                mp.prec += 2**12
        # skip calculation
        mp.prec = prec  # reset precision so that almosteq cannot fail
        if not math.isfinite(z):
            if mp.almosteq(p, mpf("1")):
                z = math.inf
            else:
                assert mp.almosteq(p, mpf("0"))
                z = -math.inf
        if use_complement:
            z = -z
        return z
    finally:
        mp.prec = prec