352件ヒット
[101-200件を表示]
(0.184秒)
種類
- インスタンスメソッド (341)
- 特異メソッド (11)
ライブラリ
- ビルトイン (315)
-
bigdecimal
/ util (11) -
json
/ add / rational (22) - mathn (4)
キーワード
- * (11)
- ** (15)
- + (11)
- -@ (8)
-
/ (11) - <=> (11)
- == (11)
- abs (8)
- ceil (11)
- coerce (11)
- convert (11)
- denominator (11)
- fdiv (11)
- floor (11)
- hash (11)
- inspect (11)
-
json
_ create (11) - magnitude (8)
-
marshal
_ dump (11) - negative? (8)
- numerator (11)
- positive? (8)
- quo (11)
- rationalize (11)
- round (11)
-
to
_ d (11) -
to
_ f (11) -
to
_ i (11) -
to
_ json (11) -
to
_ r (11) -
to
_ s (11) - truncate (11)
検索結果
先頭5件
-
Rational
# truncate(precision = 0) -> Rational | Integer (9356.0) -
小数点以下を切り捨てて値を整数に変換します。
...ision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(2, 3).to_i # => 0
Rational(3).to_i # => 3
Rational(300.6).to_i # => 300
Rational(98, 71).to_i # => 1
Rational(-31, 2).to_i # => -15
//}
precisi......か
Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').truncate(+1) # => (-617/5)
Rational('-123.456').truncate(+1).to_f # => -123.4
Rational('-123.456').truncate(0) # => -123
Rational('-123.456').truncate(-1) # => -120
//}
@see Rational#ceil, Rational#floor... -
Rational
# ceil(precision = 0) -> Integer | Rational (9325.0) -
自身と等しいかより大きな整数のうち最小のものを返します。
...を返します。
@param precision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(3).ceil # => 3
Rational(2, 3).ceil # => 1
Rational(-3, 2).ceil # => -1
//}
precision を指定した場合は指...... Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').ceil(+1) # => (-617/5)
Rational('-123.456').ceil(+1).to_f # => -123.4
Rational('-123.456').ceil(0) # => -123
Rational('-123.456').ceil(-1) # => -120
//}
@see Rational#floor, Rational#round, Rational#truncate... -
Rational
# numerator -> Integer (9319.0) -
分子を返します。
...分子を返します。
@return 分子を返します。
//emlist[例][ruby]{
Rational(7).numerator # => 7
Rational(7, 1).numerator # => 7
Rational(9, -4).numerator # => -9
Rational(-2, -10).numerator # => 1
//}
@see Rational#denominator... -
Rational
# convert(*arg) -> Rational (9301.0) -
引数を有理数(Rational)に変換した結果を返します。
...引数を有理数(Rational)に変換した結果を返します。
@param arg 変換対象のオブジェクトです。
Kernel.#Rational の本体です。
@see Kernel.#Rational... -
Rational
# fdiv(other) -> Float (9301.0) -
self を other で割った商を Float で返します。 other に虚数を指定することは出来ません。
...self を 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
# to _ json(*args) -> String (9301.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......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... -
Rational
# to _ r -> Rational (9301.0) -
自身を返します。
...自身を返します。
@return 自身を返します。
//emlist[例][ruby]{
Rational(3, 4).to_r # => (3/4)
Rational(8).to_r # => (8/1)
//}... -
Rational
# to _ s -> String (9301.0) -
自身を人間が読みやすい形の文字列表現にして返します。
..."-17/7" のように10進数の表記を返します。
@return 有理数の表記にした文字列を返します。
//emlist[例][ruby]{
Rational(3, 4).to_s # => "3/4"
Rational(8).to_s # => "8/1"
Rational(-8, 6).to_s # => "-4/3"
Rational(0.5).to_s # => "1/2"
//}
@see Rational#inspect... -
Rational
. json _ create(hash) -> Rational (9301.0) -
JSON のオブジェクトから Rational のオブジェクトを生成して返します。
...JSON のオブジェクトから Rational のオブジェクトを生成して返します。
@param hash 分子をキー 'n'、分母をキー 'd' に持つハッシュを指定します。... -
Rational
# to _ f -> Float (9219.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
//}...