def float_to_fixed_point(x: float, precision: int) -> int:
    """
    Converts the given floating point value to fixed point representation
    with the given number of fractional bits.
    """
    multiplier = 1 << precision

    width = 16 if precision >= 8 else 8
    max_val = (1 << (width - 1)) - 1
    min_val = -max_val

    fp_val = int(round(x * multiplier))

    if fp_val > max_val:
        print('WARNING: Observed positive overflow')
        return max_val
    elif fp_val < min_val:
        print('WARNING: Observed negative overflow')
        return min_val
    return fp_val