るりまサーチ

最速Rubyリファレンスマニュアル検索!
77件ヒット [1-77件を表示] (0.066秒)
トップページ > クラス:Integer[x] > クエリ:_builtin[x] > クエリ:-[x] > クエリ:modulo[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

キーワード

検索結果

Integer#modulo(other) -> Numeric (23238.0)

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

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

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

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

Integer#pow(other, modulo) -> Integer (8274.0)

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

...ram other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@rais...
...す。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなとき、警告を出したうえで Float::INF...

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

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

...ram other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@rais...
...す。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなとき、警告を出したうえで Float::INF...

Integer#pow(other) -> Numeric (8174.0)

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

...ram other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@rais...
...す。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなとき、警告を出したうえで Float::INF...

Integer#remainder(other) -> Numeric (8161.0)

self を other で割った余り r を返します。

.../emlist[][ruby]{
5.remainder(3) # => 2
-
5.remainder(3) # => -2
5.remainder(-3) # => 2
-
5.remainder(-3) # => -2

-
1234567890987654321.remainder(13731) # => -6966
-
1234567890987654321.remainder(13731.24) # => -9906.22531493148
//}

@see Integer#divmod, Integer#modulo, Numeric#modulo...

絞り込み条件を変える

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

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

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

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

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

Integer#div(other) -> Integer (8119.0)

整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

...す。

other が Integer オブジェクトの場合、Integer#/ の結果と一致します。

div に対応する剰余メソッドは modulo です。

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

//emlist[例][ruby]{
7.div(2) # => 3
7.div(-2) # => -4
7.div(2.0) # =...
...=> 3

begin
2.div(0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end

begin
2.div(0.0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
# Integer#/ と違い、引数が Float でもゼロで割ることはできない
end
//}

@see Integer#fdiv, Integer#/, Integer#modulo...