Ruby four arithmetic operations

Bullying

It will be a memo for learning

What are the four arithmetic operations?

The four arithmetic operations are addition, subtraction, multiplication, and division. The four arithmetic operations are used on worksheets and in macros. For the four arithmetic operations, create a calculation formula using the following symbols.

Four arithmetic operations

The operators for performing the basic four arithmetic operations are as follows.

operator Contents Example
* Multiply 5 * 3
/ division 8 / 2
+ Addition 3 + 6
- Subtraction 5 - 2

In addition to the four arithmetic operations, the following operators are also available.

operator Contents Example
% Surplus 5 % 3
** Exponentiation 5 ** 2

The remainder is the remainder of the operator's left side divided by the right side. The remainder of "5% 3" is "2". Exponentiation is the power of the left side of the operator with the value of the right side. "5 ** 2" becomes "25".

Recommended Posts

Ruby four arithmetic operations
[Ruby] Arithmetic progression
Various Ruby string operations