るりまサーチ

最速Rubyリファレンスマニュアル検索!
803件ヒット [1-100件を表示] (0.093秒)

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#%(other) -> Numeric (2.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}

@param other 二項演算の右側の引数(対象)
@return 計算結果

Integer#&(other) -> Integer (2.0)

ビット二項演算子。論理積を計算します。

ビット二項演算子。論理積を計算します。

@param other 数値

//emlist[][ruby]{
1 & 1 # => 1
2 & 3 # => 2
//}

Integer#*(other) -> Numeric (2.0)

算術演算子。積を計算します。

算術演算子。積を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

//emlist[][ruby]{
2 * 3 # => 6
//}

Integer#**(other) -> Numeric (2.0)

算術演算子。冪(べき乗)を計算します。

...に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。

//...

Integer#+(other) -> Numeric (2.0)

算術演算子。和を計算します。

算術演算子。和を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

//emlist[][ruby]{
3 + 4 # => 7
//}

絞り込み条件を変える

Integer#-(other) -> Numeric (2.0)

算術演算子。差を計算します。

算術演算子。差を計算します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

//emlist[][ruby]{
4 - 1 #=> 3
//}

Integer#-@ -> Integer (2.0)

単項演算子の - です。 self の符号を反転させたものを返します。

単項演算子の - です。
self の符号を反転させたものを返します。

//emlist[][ruby]{
- 10 # => -10
- -10 # => 10
//}

Integer#/(other) -> Numeric (2.0)

除算の算術演算子。

...除算の算術演算子。

other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

other が Float、Rational、Complex の場合、普通の商を other と
...
...側の引数(対象)
@return 計算結果

//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)
7 / Complex(2, 0) # => ((7/2)+0i)

begin
2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}

@see Integer#div, Integer#fdiv, Numeric#quo...
Fixnum#quo と同じ働きをします(有理数または整数を返します)。

例:

10 / 3 # => 3

require 'mathn'
10 / 3 # => (10/3)

Integer#<(other) -> bool (2.0)

比較演算子。数値として小さいか判定します。

比較演算子。数値として小さいか判定します。

@param other 比較対象の数値
@return self よりも other が大きい場合 true を返します。
そうでなければ false を返します。

//emlist[][ruby]{
1 < 1 # => false
1 < 2 # => true
//}

Integer#<<(bits) -> Integer (2.0)

シフト演算子。bits だけビットを左にシフトします。

シフト演算子。bits だけビットを左にシフトします。

@param bits シフトさせるビット数

//emlist[][ruby]{
printf("%#b\n", 0b0101 << 1) # => 0b1010
p -1 << 1 # => -2
//}

絞り込み条件を変える

<< 1 2 3 ... > >>