def METHOD_NAME(float_val: float) -> float:
    if min_float <= float_val <= max_float:
        return float_val
    if float_val == 0.0 and allow_zero:
        return float_val
    # Outside bounds; pick a new value, sampled from the allowed range,
    # using the mantissa bits.
    mant = float_to_int(float_val) & mantissa_mask
    float_val = min_float + range_size * (mant / mantissa_mask)
    # Re-enforce the bounds (just in case of floating point arithmetic error)
    return max(min_float, min(max_float, float_val))