るりまサーチ

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

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l
  5. l matrix

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

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

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

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

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

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

BigDecimal#modulo(n) -> BigDecimal (21201.0)

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

...self を n で割った余りを返します。

@param n self を割る数を指定します。

//emlist[][ruby]{
require 'bigdecimal'
x = BigDecimal((2**100).to_s)
( x % 3).to_i # => 1
(-x % 3).to_i # => 2
( x % -3).to_i # => -2
(-x % -3).to_i # => -1
//}

戻り値は n と同じ符号にな...
...ります。これは BigDecimal#remainder とは
異なる点に注意してください。詳細は Numeric#%、
Numeric#remainder を参照して下さい。...

Bignum#modulo(other) -> Fixnum | Bignum | Float (18301.0)

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

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

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

Fixnum#modulo(other) -> Fixnum | Bignum | Float (18301.0)

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

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

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

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

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

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

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

* self == other * q + r

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

をみたす数です。
余り r は、other と同じ符号になります...
...ます。
modulo
はメソッド % の呼び出しとして定義されています。

@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#modulo(other) -> Numeric (18201.0)

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

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

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

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

BigDecimal#%(n) -> BigDecimal (3101.0)

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

...self を n で割った余りを返します。

@param n self を割る数を指定します。

//emlist[][ruby]{
require 'bigdecimal'
x = BigDecimal((2**100).to_s)
( x % 3).to_i # => 1
(-x % 3).to_i # => 2
( x % -3).to_i # => -2
(-x % -3).to_i # => -1
//}

戻り値は n と同じ符号にな...
...ります。これは BigDecimal#remainder とは
異なる点に注意してください。詳細は Numeric#%、
Numeric#remainder を参照して下さい。...

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

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

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

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

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

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

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

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

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

* self == other * q + r

* other > 0 のとき: 0 <=...
...ます。

@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...

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

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

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

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

//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::INFINI...
...TY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。

@see BigDecimal#power...

絞り込み条件を変える

Bignum#remainder(other) -> Fixnum | Bignum | Float (112.0)

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

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

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

@param other self を割る数。

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

Bignum#%(other) -> Fixnum | Bignum | Float (101.0)

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

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

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