본문 바로가기

old/Programming

inclusive와 exclusive의 차이점

반응형

정의

프로그래밍 문제에서 inclusive/exclusive는 숫자 범위를 의미합니다.

Inclusive - 가장 마지막 번호를 포함한다
Exclusive - 가장 마지막 번호를 포함하지 않는다

Example

inclusive

If a function will compute $2^i$ where $i = 1, 2, ..., n$.
$i$ can have values from 1 up to and including the value n.

이 뜻은 마지막 숫자를 포함합니다.

1 through 10 (inclusive) = [1, 10]
1 2 3 4 5 6 7 8 9 10

exclusive

If a function will compute $2^i$ where $i = 1, 2, ..., n$
i can have values from 1 up to and excluding the value n.

이 뜻은 마지막 숫자를 포함하지 않습니다.

1 through 10 (exclusive) = [1, 10)
1 2 3 4 5 6 7 8 9

1 through 10 (exclusive) = [1, 10) 1 2 3 4 5 6 7 8 9

반응형