るりまサーチ (Ruby 2.5.0)

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

別のキーワード

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

ライブラリ

キーワード

検索結果

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

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

...す。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#convert(*arg) -> Rational (27691.0)

引数を有理数(Rational)に変換した結果を返します。

...引数を有理数(Rational)に変換した結果を返します。

@param arg 変換対象のオブジェクトです。

Kernel.#Rational の本体です。

@see Kernel.#Rational...

Rational#to_json(*args) -> String (27358.0)

自身を JSON 形式の文字列に変換して返します。

...JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 使用しません。

//emlist[例][ruby]{
require 'json/add/rational'
Rational
(1, 3).to_json # => "{\"json_class\":\"Rational\",\"n\":1,\"d\":3}"
//}

@see JSON::Generator::GeneratorMethods::Hash#to_json...