373件ヒット
[201-300件を表示]
(0.119秒)
ライブラリ
- ビルトイン (345)
-
bigdecimal
/ util (12) -
json
/ add / rational (12) - mathn (4)
キーワード
- * (12)
- ** (16)
- + (12)
- - (12)
- -@ (9)
-
/ (12) - <=> (12)
- == (12)
- abs (9)
- ceil (12)
- coerce (12)
- convert (12)
- denominator (12)
- fdiv (12)
- floor (12)
- hash (12)
- inspect (12)
- magnitude (9)
-
marshal
_ dump (12) - negative? (9)
- numerator (12)
- positive? (9)
- quo (12)
- rationalize (12)
- round (12)
-
to
_ d (12) -
to
_ f (12) -
to
_ i (12) -
to
_ json (12) -
to
_ r (12) -
to
_ s (12) - truncate (12)
検索結果
先頭5件
-
Rational
# / (other) -> Rational | Float (3102.0) -
商を計算します。
...//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 # => ZeroDivisionError
//}
@raise ZeroDivisionError other が 0 の時に発生します。
@see Numeric#quo... -
Rational
# <=>(other) -> -1 | 0 | 1 | nil (3102.0) -
self と other を比較して、self が大きい時に 1、等しい時に 0、小さい時に -1 を返します。比較できない場合はnilを返します。
...場合はnilを返します。
@param other 自身と比較する数値
@return -1 か 0 か 1 か nil を返します。
//emlist[例][ruby]{
Rational(2, 3) <=> Rational(2, 3) # => 0
Rational(5) <=> 5 # => 0
Rational(2, 3) <=> Rational(1,3) # => 1
Rational(1, 3) <=>......1 # => -1
Rational(1, 3) <=> 0.3 # => 1
Rational(1, 3) <=> nil # => nil
//}... -
Rational
# abs -> Rational (3102.0) -
自身の絶対値を返します。
...自身の絶対値を返します。
//emlist[例][ruby]{
Rational(1, 2).abs # => (1/2)
Rational(-1, 2).abs # => (1/2)
//}... -
Rational
# convert(*arg) -> Rational (3102.0) -
引数を有理数(Rational)に変換した結果を返します。
...引数を有理数(Rational)に変換した結果を返します。
@param arg 変換対象のオブジェクトです。
Kernel.#Rational の本体です。
@see Kernel.#Rational... -
Rational
# hash -> Integer (3102.0) -
自身のハッシュ値を返します。
自身のハッシュ値を返します。
@return ハッシュ値を返します。
@see Object#hash -
Rational
# numerator -> Integer (3102.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
# quo(other) -> Rational | Float (3102.0) -
商を計算します。
...//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 # => ZeroDivisionError
//}
@raise ZeroDivisionError other が 0 の時に発生します。
@see Numeric#quo... -
Rational
# round(precision = 0) -> Integer | Rational (3102.0) -
自身ともっとも近い整数を返します。
...げされます。
@param precision 計算結果の精度
@raise TypeError precision に整数以外のものを指定すると発生します。
//emlist[例][ruby]{
Rational(3).round # => 3
Rational(2, 3).round # => 1
Rational(-3, 2).round # => -2
//}
precision を指定した場合は指......に最も近い整
数か Rational を返します。
//emlist[例][ruby]{
Rational('-123.456').round(+1) # => (-247/2)
Rational('-123.456').round(+1).to_f # => -123.5
Rational('-123.456').round(0) # => -123
Rational('-123.456').round(-1) # => -120
Rational('-123.456').round(-2)......# => -100
//}
@see Rational#ceil, Rational#floor, Rational#truncate... -
Rational
# to _ json(*args) -> String (3102.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...