관계연산자
외관
(==에서 넘어옴)
컴퓨터 과학에서 관계연산자(relational operator)는 '두 개의 값을 비교해 그들간의 관계를 평가'하는 연산자로, 2개의 실체 간의 특정한 종류의 관계를 시험하거나 정의하는 프로그래밍 언어 구조체 또는 연산자이다. 여기에는 숫자의 등식(예: 5 = 5)이나 부등식(예: 4 ≥ 3)이 포함된다.
표준 관계연산자
[편집]프로그래밍 언어에 쓰이는 가장 흔한 숫자 관계연산자는 아래와 같다.
| 규칙 | 같음 | 같지 않음 | 보다 큼 | 보다 작음 | 보다 크거나 같음 |
보다 작거나 같음 |
|---|---|---|---|---|---|---|
| 인쇄물 | = | ≠ | > | < | ≥ | ≤ |
| 포트란[note 1] | .EQ. |
.NE. |
.GT. |
.LT. |
.GE. |
.LE. |
| 알골 68[note 2] | = |
≠ |
> |
< |
≥ |
≤ |
/= |
>= |
<= | ||||
eq |
ne |
gt |
lt |
ge |
le | |
| APL | = |
≠ |
> |
< |
≥ |
≤ |
| 베이직, ML, 파스칼[note 3] | = |
<> |
> |
< |
>= |
<= |
| MUMPS | = |
'= |
> |
< |
'< |
'> |
| 루아 | == |
~= |
> |
< |
>= |
<= |
| C 계열[note 4] | == |
!= |
> |
< |
>= |
<= |
| 본 계열 셸[note 5] | -eq |
-ne |
-gt |
-lt |
-ge |
-le |
| 배치 파일 | EQU |
NEQ |
GTR |
LSS |
GEQ |
LEQ |
| MATLAB[note 6] | == |
~= |
> |
< |
>= |
<= |
eq(x,y) |
ne(x,y) |
gt(x,y) |
lt(x,y) |
ge(x,y) |
le(x,y) | |
| 포트란 90[note 7], 하스켈 | == |
/= |
> |
< |
>= |
<= |
| 매스매티카[1] | == |
!= |
> |
< |
>= |
<= |
Equal[x,y] |
Unequal[x,y] |
Greater[x,y] |
Less[x,y] |
GreaterEqual[x,y] |
LessEqual[x,y] |
같이 보기
[편집]각주
[편집]내용주
[편집]- ↑ Including FORTRAN II, III, IV, 66 and 77.
- ↑ ALGOL 68: stropping regimes are used in code on platforms with limited character sets (e.g., use
>=orGEinstead of≥), platforms with noboldemphasis (use'ge'), or platforms with only UPPERCASE (use.GEor'GE'). - ↑ Including ALGOL, Simula, Modula-2, Eiffel, SQL, spreadsheet formulas, and others.
- ↑ C, C++, C#, Go, 자바, 자바스크립트, 펄 (숫자 비교만), PHP, 파이썬, 루비, R 포함.
- ↑ 본 셸, 배시, 콘 셸, 윈도우 파워셸 포함. The symbols
<and>are usually used in a shell for redirection, so other symbols must be used. Without the hyphen, is used in Perl for string comparison. - ↑ MATLAB, although in other respects using similar syntax as C, does not use
!=, as!in MATLAB sends the following text as a command line to the operating system. The first form is also used in 스몰토크, with the exception of equality, which is=. - ↑ Including FORTRAN 95, 2003, 2008 and 2015.