def METHOD_NAME(x, round: bool, is_signed: bool, width: int, int_width=None):
    with_prefix = False
    # If `int_width` is not defined, then this is a `Bitnum`
    if int_width is None:
        return Bitnum(x, width, is_signed).hex_string(with_prefix)
    try:
        return FixedPoint(x, width, int_width, is_signed).hex_string(with_prefix)
    except InvalidNumericType as error:
        if round:
            # Only round if it is not already representable.
            fractional_width = width - int_width
            x = float_to_fixed(float(x), fractional_width)
            x = str(x)
            return FixedPoint(x, width, int_width, is_signed).hex_string(with_prefix)
        else:
            raise error