るりまサーチ

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

別のキーワード

  1. bigdecimal div
  2. _builtin div
  3. integer div
  4. numeric div

ライブラリ

クラス

検索結果

<< 1 2 3 ... > >>

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

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

...

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 => e
e # => #<ZeroDivisionError: div...
...ided by 0>
end

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

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

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

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

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

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

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

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

BigDecimal#div(other, n) -> BigDecimal (18101.0)

商を計算します。

商を計算します。

self / other を最大で n 桁まで計算します。計算結果の精度が n より大きい
ときは BigDecimal.mode で指定された方法で丸められます。

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

@param n 有効桁数を整数で指定します。省略するか 0 を指定した場合は
BigDecimal#/ と同じ値を返します。

@raise ArgumentError n に負の数を指定した場合に発生します。

@see BigDecimal#/

BigDecimal#div(other) -> BigDecimal (15101.0)

商を計算します。

商を計算します。

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

詳細は Numeric#quo を参照して下さい。

計算結果の精度についてはlib:bigdecimal#precisionを参照してください。

Bignum#div(other) -> Fixnum | Bignum | Float (15101.0)

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

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

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

絞り込み条件を変える

Fixnum#div(other) -> Fixnum | Bignum | Float (15101.0)

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

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

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

Integer#fdiv(other) -> Numeric (6112.0)

self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。

...指定します。

例:

654321.fdiv(13731) # => 47.652829364212366
654321.fdiv(13731.24) # => 47.65199646936475

-1234567890987654321.fdiv(13731) # => -89910996357705.52
-1234567890987654321.fdiv(13731.24) # => -89909424858035.72
@see Numeric#quo, Numeric#div, Integer#div...

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

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

...数です。
div
mod が返す商は Numeric#div と同じです。
また余りは、Numeric#modulo と同じです。
このメソッドは、メソッド / と % によって定義されています。

@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] (6106.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...

BigDecimal#divmod(n) -> [BigDecimal, BigDecimal] (6100.0)

self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし て返します。

...り r を、 [q, r] という 2 要素の配列にし
て返します。

商は負の無限大負方向に丸められます。

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

//emlist[][ruby]{
require 'bigdecimal'

a = BigDecimal("42")
b = BigDecimal("9")

a.divmod(b) # => [0.4e1, 0.6e1]
//}...

絞り込み条件を変える

BigDecimal::EXCEPTION_ZERODIVIDE -> Integer (6100.0)

BigDecimal に 0 による割り算を実行した場合に例外を発生させるかど うかを設定、確認する際の値を返します。

BigDecimal に 0 による割り算を実行した場合に例外を発生させるかど
うかを設定、確認する際の値を返します。

BigDecimal.mode の第 1 引数に指定します。
<< 1 2 3 ... > >>