def _normalize_number(number, intmax):
    """ Return 0.0 <= number <= 1.0 or None if the number is invalid. """
    if isinstance(number, float) and 0.0 <= number <= 1.0:
        return number
    elif isinstance(number, int) and 0 <= number <= intmax:
        return number / intmax
    return None