freeCodeCamp/guide/chinese/ruby/ruby-numbers-operations/index.md

29 lines
828 B
Markdown
Raw Normal View History

---
title: Ruby Numbers Operations
localeTitle: Ruby Numbers操作
---
在Ruby中您可以对数字执行所有标准数学运算包括加`+` ,减法`-` ,乘法`*` ,除法`/` ,查找余数`%` ,以及使用指数`**` 。
## 加成:
* 可以使用`+`运算符将数字相加。 `ruby 15 + 25 #=> 40`
## 减法:
* 可以使用`-`运算符将数字相互减去。 `ruby 25 - 15 #=> 10`
## 乘法:
* 可以使用`*`运算符将数字相乘。 `ruby 10 * 5 #=> 50`
## 师:
* 可以使用`/`运算符将数字相互分开。 `ruby 10 / 5 #=> 2`
## 余:
* 可以使用模数`%`运算符找到剩余。 `ruby 10 % 3 #=> 1 # because the remainder of 10/3 is 1`
## 指数:
* 可以使用`**`运算符计算指数。 `ruby 2 ** 3 #=> 8 # because 2 to the third power, or 2 * 2 * 2 = 8`