るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

Rational#to_f -> Float (8124.0)

自身の値を最も良く表現する Float に変換します。

...する Float に変換します。

絶対値が極端に小さい、または大きい場合にはゼロや無限大が返ることがあります。

@return Float を返します。

//emlist[例][ruby]{
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
(1, 10**1000).to_f # => 0.0
Rational
(-1, 10**1000).to_f # => -0.0
Rational
(10**1000).to_f # => Infinity
Rational
(-10**1000).to_f # => -Infinity
//}...

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

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

...を other 乗する数

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

//emlist[例][ruby]{
r = Rational(3, 4)
r ** Rational(2, 1) # => (9/16)
r ** 2...
...# => (9/16)
r ** 2.0 # => 0.5625
r ** Rational(1, 2) # => 0.866025403784439
//}...

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

self を other で割った商を Float で返します。 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).fdiv(Complex(0, 1)) # => RangeError
//}...

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

商を計算します。

...ram other 自身を割る数

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

//emlist[例][ruby]{
r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / 0.5 # => 1.5
r / Rational(1, 2) # => (3/2)
r / 0...

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

商を計算します。

...ram other 自身を割る数

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

//emlist[例][ruby]{
r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / 0.5 # => 1.5
r / Rational(1, 2) # => (3/2)
r / 0...

絞り込み条件を変える

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

積を計算します。

...

@param other 自身に掛ける数

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

//emlist[例][ruby]{
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 (8114.0)

和を計算します。

...和を計算します。

@param other 自身に足す数

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

//emlist[例][ruby]{
r = Rational(3, 4)
r + Rational(1, 2) # => (5/4)
r + 1 # => (7/4)
r + 0.5 # => 1.25
//}...

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

差を計算します。

...差を計算します。

@param other 自身から引く数

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

//emlist[例][ruby]{
r = Rational(3, 4)
r - 1 # => (-1/4)
r - 0.5 # => 0.25
//}...