るりまサーチ (Ruby 2.3.0)

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

別のキーワード

  1. _builtin rational
  2. rational **
  3. json/add/rational to_json
  4. json/add/rational json_create
  5. rational fdiv

ライブラリ

クラス

キーワード

検索結果

Rational#fdiv(other) -> Float (117487.0)

self を other で割った商を Float で返します。 other に虚数を指定することは出来ません。

self を other で割った商を Float で返します。
other に虚数を指定することは出来ません。

@param other 自身を割る数

//emlist[例][ruby]{
Rational(2, 3).fdiv(1) # => 0.6666666666666666
Rational(2, 3).fdiv(0.5) # => 1.3333333333333333
Rational(2).fdiv(3) # => 0.6666666666666666

Rational(1).fdiv(Complex(1, 0)) # => 1.0
Rational(1)...

Numeric#quo(other) -> Rational | Float | Complex (361.0)

self を other で割った商を返します。 整商を得たい場合は Numeric#div を使ってください。

self を other で割った商を返します。
整商を得たい場合は Numeric#div を使ってください。

Numeric#fdiv が結果を Float で返すメソッドなのに対して quo はなるべく正確な数値を返すことを意図しています。
具体的には有理数の範囲に収まる計算では Rational の値を返します。
Float や Complex が関わるときはそれらのクラスになります。

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。


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

//emlist[例][ruby]{
1.quo(3)...

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

除算の算術演算子。

除算の算術演算子。

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

other が Float、Rational、Complex の場合、普通の商を other と
同じクラスのインスタンスで返します。

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

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

Integer#div(other) -> Integer (40.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 => ...