LoginSignup
4
5

More than 5 years have passed since last update.

Rubyの算術演算

Last updated at Posted at 2015-03-18

Rubyの算術演算についてまとめてみます。

演算子
メソッド
内容 備考
+ 加算
- 減算
* 乗算
/ 除算
quo 除算 Floatオブジェクトを用いていない場合、
演算結果をRationalオブジェクトで返す
div
%
modulo
剰余
remainder 剰余 x.remainder(y)の場合、演算結果はxと同符号となる
divmod 商と剰余 演算結果を[商,剰余]の形式で返す
** べき乗 Floatオブジェクトを用いていない負のべき乗の場合、
演算結果をRationalオブジェクトで返す
4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5