Files
freeCodeCamp/guide/chinese/ruby/ruby-numbers-operations/index.md
2018-10-16 21:32:40 +05:30

29 lines
828 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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`