def color_float_to_hex(r, g, b):
    """Convert RGB to hex."""
    def clamp(x):
        x = round(x*255)
        return max(0, min(x, 255))
    return "#{0:02x}{1:02x}{2:02x}".format(clamp(r), clamp(g), clamp(b))