70件ヒット
[1-70件を表示]
(0.115秒)
ライブラリ
- ビルトイン (55)
-
json
/ add / rational (11) - mathn (4)
検索結果
先頭5件
-
Rational
# *(other) -> Rational | Float (27238.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)
//}... -
Complex
# *(other) -> Complex (18125.0) -
積を計算します。
...積を計算します。
@param other 自身に掛ける数
//emlist[例][ruby]{
Complex(1, 2) * 2 # => (2+4i)
Complex(1, 2) * Complex(2, 3) # => (-4+7i)
Complex(1, 2) * Rational(1, 2) # => ((1/2)+(1/1)*i)
//}... -
Rational
# **(other) -> Rational | Float (15220.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
# **(rhs) -> Numeric (15113.0) -
@todo
...@todo
self のべき乗を返します。 Rational になるようであれば Rational で返します。... -
Rational
# convert(*arg) -> Rational (9230.0) -
引数を有理数(Rational)に変換した結果を返します。
...引数を有理数(Rational)に変換した結果を返します。
@param arg 変換対象のオブジェクトです。
Kernel.#Rational の本体です。
@see Kernel.#Rational... -
Rational
# to _ json(*args) -> String (9119.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......@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json
に渡されます。
//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... -
String
# to _ r -> Rational (160.0) -
自身を有理数(Rational)に変換した結果を返します。
...理数(Rational)に変換した結果を返します。
Kernel.#Rational に文字列を指定した時のように、以下のいずれかの形
式で指定します。
* "1/3" のような分数の形式
* "0.3" のような10進数の形式
* "0.3E0" のような x.xEn の形式
* 数字.......2'.to_r # => (-46/5)
'-9.2E2'.to_r # => (-920/1)
'1_234_567'.to_r # => (1234567/1)
'1_234/5_678'.to_r # => (617/2839)
//}
Kernel.#Rational に文字列を指定した時とは異なる点もあります。
途中に変換できないような文字列が入っていた場合は、......# => (21/1)
'21/06/09'.to_r # => (7/2) # 21/6 を約分して 7/2。
//}
変換できないような文字列を指定した場合は 0/1 を返します。
//emlist[][ruby]{
'foo'.to_r # => (0/1)
''.to_r # => (0/1)
'bwv 1079'.to_r # => (0/1)
//}
@see Kernel.#Rational...