학교에서 배운 산술 연산(가감승제)을 기억하는가? 이 산술 연산자는 그것처럼 동작한다.
표 11-1. Arithmetic Operators
Example | Name | Result |
---|---|---|
$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.