11. 장. 연산자 (Operators)

차례
산술 연산자 (Arithmetic Operators)
대입 연산자 (Assignment Operators)
Bit 단위 연산자 (Bitwise Operators)
비교 연산자 (Comparison Operators)
오류 제어 연산자 (Error control Operators)
실행 연산자 (Execution Operators)
증가/감소 연산자 (Incrementing/Decrementing Operators)
Logical Operators
연산자 우선 순위 (Operator Precedence)
문자열 연산자 (String Operators)

산술 연산자 (Arithmetic Operators)

학교에서 배운 산술 연산(가감승제)을 기억하는가? 이 산술 연산자는 그것처럼 동작한다.

표 11-1. Arithmetic Operators

ExampleNameResult
$a + $b덧셈(Addition)$a와 $b의 합.
$a - $b뺄셈(Subtraction)$a에서 $b를 뺀 값.
$a * $b곱셈(Multiplication)$a와 $b의 곱.
$a / $b나눗셈(Division)$a에서 $b를 나눈 값(혹 은 몫).
$a % $b나머지(Modulus)$a에서 $b를 나눈 나머지.

The division operator ("/") returns an integer value (the result of an integer division) if the two operands are integers (or strings that get converted to integers) and the quotient is an integer. If either operand is a floating-point value, or the operation results in a non-integer value, a floating-point value is returned.