るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.071秒)
トップページ > ライブラリ:ビルトイン[x] > バージョン:2.1.0[x] > クエリ:_builtin[x] > クエリ:float[x] > クエリ:at[x] > クエリ:*[x] > クエリ:Rational[x]

別のキーワード

  1. _builtin float
  2. float rationalize
  3. float to_d
  4. json float
  5. fiddle type_float

クラス

検索結果

Rational (156223.0)

有理数を扱うクラスです。

有理数を扱うクラスです。

「1/3」のような有理数を扱う事ができます。Integer や Float
と同様に Rational.new ではなく、 Kernel.#Rational を使用して
Rational オブジェクトを作成します。

//emlist[例][ruby]{
Rational(1, 3) # => (1/3)
Rational('1/3') # => (1/3)
Rational('0.33') # => (33/100)
Rational.new(1, 3) # => NoMethodError
//}

Rational オブジェク...

Rational#*(other) -> Rational | Float (151657.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 (115621.0)

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

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

@param other 自身を 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.866...