def METHOD_NAME(aperture):
    # see https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/Canon.pm#L9678
    """Transform aperture value to Canon maker note style hex format."""
    # for apertures < 1 the below is negative
    num = math.log(aperture) * 2 / math.log(2)
    # temporarily make the number positive
    if num < 0:
        num = -num
        sign = -1
    else:
        sign = 1
    val = int(num)
    frac = num - val
    if abs(frac - 0.33) < 0.05:
        frac = 0x0C
    elif abs(frac - 0.67) < 0.05:
        frac = 0x14
    else:
        frac = int(frac * 0x20 + 0.5)
    return sign * (val * 0x20 + frac)