るりまサーチ (Ruby 3.0)

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

Numeric#modulo(other) -> Numeric (69433.0)

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

...す。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
p 13.modulo(4) #=> 1
p (11.5).modulo(3.5) #=> 1.0
p 13.modulo(-4) #=> -3
p (-13).modulo(4) #=> 3
p (-13).modulo(-4) #=> -1
p (-11).modulo(3.5) #=> 3.0
//}

@see Numeric#divmod, Numeric#remainder...

Float#modulo(other) -> Float (69307.0)

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

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

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

//emlist[例][ruby]{
# 剰余
3.0
% 1.2 # => 0.6000000000000001
3.0
% 0.0 # ZeroDivisionError
//}...

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

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

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

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

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

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

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

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

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

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
...

Numeric#%(other) -> Numeric (24133.0)

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

...す。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
p 13.modulo(4) #=> 1
p (11.5).modulo(3.5) #=> 1.0
p 13.modulo(-4) #=> -3
p (-13).modulo(4) #=> 3
p (-13).modulo(-4) #=> -1
p (-11).modulo(3.5) #=> 3.0
//}

@see Numeric#divmod, Numeric#remainder...

絞り込み条件を変える

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

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

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

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

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
...

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

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

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

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

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
...

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

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

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

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

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

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

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

begin
2.div(0)
rescue => ...

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

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

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

r の符号は self と同じになります。

@param other self を割る数。

//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) #...

Numeric#divmod(other) -> [Numeric] (24040.0)

self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。

...ています。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
11.divmod(3) #=> [3, 2]
(11.5).divmod(3.5) #=> [3, 1.0]
11.divmod(-3) #=> [-4, -1]
11.divmod(3.5) #=> [3, 0.5]
(-11).divmod(3.5) #=> [-4, 3.0]
//}

@see Numeric#div, Numeric#modulo...

絞り込み条件を変える

Float#divmod(other) -> [Numeric] (24022.0)

self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。

...ます。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
11.divmod(3) # => [3, 2]
(11.5).divmod(3.5) # => [3, 1.0]
11.divmod(-3) # => [-4, -1]
11.divmod(3.5) # => [3, 0.5]
(-11).divmod(3.5) # => [-4, 3.0]
//}

@see Numeric#div, Numeric#modulo...

Numeric#div(other) -> Integer (24022.0)

self を other で割った整数の商 q を返します。

...メソッド / を呼びだし、floorを取ることで計算されます。

メソッド / の定義はサブクラスごとの定義を用います。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
p 3.div(2) # => 1
p (-3).div(2) # => -2
p (-3.0).div(2) # => -2
//}...

Numeric#remainder(other) -> Numeric (24022.0)

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

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

ここで、商 q と余り r は、

* self == other * q + r


* self > 0 のとき 0 <= r < |other|
* self < 0 のとき -|other| < r <= 0
* q は整数

をみたす数です。r の符号は self と同じになります。
商 q を直接返すメソッドはありません。self.quo(other).truncate がそれに相当します。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
p 13....

Float#%(other) -> Float (24007.0)

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

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

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

//emlist[例][ruby]{
# 剰余
3.0
% 1.2 # => 0.6000000000000001
3.0
% 0.0 # ZeroDivisionError
//}...

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

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

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

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

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

絞り込み条件を変える