るりまサーチ

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

関連するキーワード

  1. _builtin float
  2. to_f float

ライブラリ

キーワード

検索結果

Rational#**(other) -> Rational | Float (126)

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

...自身を other 乗する数

other に Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、計算結果が無理数だった場合は Float
を返します。

例:

r = Rational(3, 4)
r ** Rational(2, 1) # => (9/16)
r ** 2...
...r ** Rational(1, 2) # => 0.866025403784439

注意:

1.8 系とは計算結果のオブジェクトが異なる場合がある事に注意してください。
other に Rational を指定した場合には戻り値は必ず Float を返
していました。

# 1.8.7 の場合
r = Rational(3,...
...4)
r ** Rational(2, 1) # => 0.5625...

Rational#to_f -> Float (118)

自身を Float に変換します。

...自身を Float に変換します。

@return 実数を返します。

例:

Rational
(9, 4).to_f # => 2.25
Rational
(-3, 4).to_f # => -0.75
Rational
(20, 3).to_f # => 6.666666666666667...
...自身を Float に変換します。

@return 実数を返します。

例:

Rational
(2).to_f # => 2.0
Rational
(9, 4).to_f # => 2.25
Rational
(-3, 4).to_f # => -0.75
Rational
(20, 3).to_f # => 6.666666666666667...

Rational#/(other) -> Rational | Float (115)

商を計算します。

...します。

@param other 自身を割る数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / Rational(1, 2) # => (3/2)
r / 0 # => ZeroDivisi...

Rational#quo(other) -> Rational | Float (115)

商を計算します。

...します。

@param other 自身を割る数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / Rational(1, 2) # => (3/2)
r / 0 # => ZeroDivisi...

Rational#*(other) -> Rational | Float (114)

積を計算します。

...other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

Rational
(3, 4) * 2 # => Rational(3, 2)
Rational
(3, 4) * 4 # => Rational(3, 1)
Rational
(3, 4) * 0.5 # => 0.375
Rational
(3, 4) * Rational(1, 2) # => Rational(3, 8)...
...other に 0 を指定した場合も Rational を返します。

Rational
(3, 4) * 0 # => Rational(0, 1)...
...します。

@param other 自身に掛ける数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

r = Rational(3, 4)
r * 2 # => (3/2)
r * 4 # => (3/1)
r * 0.5 # => 0.375
r * Rational(1, 2) # => (3/8)...

絞り込み条件を変える

Rational#+(other) -> Rational | Float (114)

和を計算します。

...算します。

@param other 自身に足す数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

Rational
(3, 4) + 2 # => Rational(11, 4)
Rational
(3, 4) + Rational(2, 1) # => Rational(11, 4)
Rational
(3, 4) + 2.0 # => 2.75...
...和を計算します。

@param other 自身に足す数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

r = Rational(3, 4)
r + Rational(1, 2) # => (5/4)
r + 1 # => (7/4)
r + 0.5 # => 1.25...

Rational#-(other) -> Rational | Float (114)

差を計算します。

...差を計算します。

@param other 自身から引く数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

Rational
(3, 4) - 1 # => Rational(-1, 4)
Rational
(3, 4) - 0.5 # => 0.25...
...差を計算します。

@param other 自身から引く数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

r = Rational(3, 4)
r - 1 # => (-1/4)
r - 0.5 # => 0.25...

Rational#/(other) -> Rational | Float (114)

商を計算します。

...身を割る数

other に Float を指定した場合は、計算結果を Float で返しま
す。

例:

Rational
(3, 4) / 2 # => Rational(3, 8)
Rational
(3, 4) / Rational(2, 1) # => Rational(3, 8)
Rational
(3, 4) / 2.0 # => 0.375
Rational
(3, 4) / 0 # =>...

Rational#divmod(other) -> [Integer, Float | Rational] (114)

self を other で割った、商と余りの配列を返します。

... Float を指定した場合は、余りを Float で返します。

@param other 自身を割る数

例:

Rational
(3,4).divmod(Rational(2,3)) # => [1, Rational(1, 12)]
Rational
(-3,4).divmod(Rational(2,3)) # => [-2, Rational(7, 12)]
Rational
(3,4).divmod(Rational(-2,3)) # => [-2, Rational(-7...
..., 12)]

Rational
(9,4).divmod(2) # => [1, Rational(1, 4)]
Rational
(9,4).divmod(Rational(2, 1)) # => [1, Rational(1, 4)]
Rational
(9,4).divmod(2.0) # => [1, 0.25]

@see Numeric#divmod...

Rational#**(other) -> Rational | Float (108)

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

...した場合は、計算結果を Rational で返します。
other に整数以外を指定した場合は計算結果を Float で返します。

例:

Rational
(3, 4) ** 2 # => Rational(9, 16)
Rational
(3, 4) ** Rational(2, 1) # => 0.5625
Rational
(3, 4) ** 2.0 # => 0....
...5625

注意:

1.9 系とは計算結果のオブジェクトが異なる場合がある事に注意してください。
other に Rational を指定した場合には戻り値が Rational を返
す場合があります。

# 1.9.1 の場合
Rational
(3, 4) ** Rational(2, 1) # => (9/16)...

絞り込み条件を変える

Rational#%(other) -> Rational | Float (102)

剰余を計算します。絶対値が self の絶対値を越えない、符号が self と同じ Numeric を返します。

...。絶対値が self の絶対値を越えない、符号が self と同じ
Numeric を返します。

@param other 自身を割る数

例:

Rational
(3, 4) % 2 # => Rational(3, 4)
Rational
(3, 4) % Rational(2, 1) # => Rational(3, 4)
Rational
(3, 4) % 2.0 # => 0.75...

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

自身を other で割った実数の商を返します。

...を other で割った実数の商を返します。

@param other 自身を割る数

例:

Rational
(2, 3).fdiv(1) # => 0.6666666666666666
Rational
(2, 3).fdiv(0.5) # => 1.3333333333333333
Rational
(2).fdiv(3) # => 0.6666666666666666...