What is the meaning of “exclusive” and “inclusive” when describing number ranges?

前端 未结 3 1642
野趣味
野趣味 2021-02-01 05:23

Simple question but, I see exclusive and inclusive when referring to number ranges.

For example, this is a line from an algorithms book:

The follo

3条回答
  •  佛祖请我去吃肉
    2021-02-01 05:47

    In simple terms, inclusive means within and the number n, while exclusive means within and without the number n.

    Note: that each argument should be marked its "clusivity"/ "participation"

    # 1 (inclusive) through 5 (inclusive)
    1 <= x <= 5 == [1, 2, 3, 4, 5]
    
    # 1 (inclusive) through 5 (exclusive)
    1 <= x < 5 == [1, 2, 3, 4]
    
    # 1 (exclusive) through 5 (inclusive)
    1 < x <= 5 == [2, 3, 4, 5]
    
    # 1 (exclusive) through 5 (exclusive)
    1 < x < 5 == [2, 3, 4]
    

提交回复
热议问题