352件ヒット
[101-200件を表示]
(0.023秒)
別のキーワード
種類
- インスタンスメソッド (341)
- 特異メソッド (11)
ライブラリ
- ビルトイン (315)
-
bigdecimal
/ util (11) -
json
/ add / rational (22) - mathn (4)
キーワード
- * (11)
- ** (15)
- + (11)
- - (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
# abs -> Rational (21115.0) -
自身の絶対値を返します。
...自身の絶対値を返します。
//emlist[例][ruby]{
Rational(1, 2).abs # => (1/2)
Rational(-1, 2).abs # => (1/2)
//}... -
Rational
# magnitude -> Rational (21115.0) -
自身の絶対値を返します。
...自身の絶対値を返します。
//emlist[例][ruby]{
Rational(1, 2).abs # => (1/2)
Rational(-1, 2).abs # => (1/2)
//}... -
Rational
# quo(other) -> Rational | Float (21115.0) -
商を計算します。
...定した場合は、計算結果を Float で返します。
//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 ZeroDivisionErr... -
Rational
# *(other) -> Rational | Float (21114.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 (21114.0) -
和を計算します。
...和を計算します。
@param other 自身に足す数
other に Float を指定した場合は、計算結果を Float で返しま
す。
//emlist[例][ruby]{
r = Rational(3, 4)
r + Rational(1, 2) # => (5/4)
r + 1 # => (7/4)
r + 0.5 # => 1.25
//}... -
Rational
# to _ r -> Rational (21114.0) -
自身を返します。
...自身を返します。
@return 自身を返します。
//emlist[例][ruby]{
Rational(3, 4).to_r # => (3/4)
Rational(8).to_r # => (8/1)
//}... -
Rational
# -(other) -> Rational | Float (21108.0) -
差を計算します。
...差を計算します。
@param other 自身から引く数
other に Float を指定した場合は、計算結果を Float で返しま
す。
//emlist[例][ruby]{
r = Rational(3, 4)
r - 1 # => (-1/4)
r - 0.5 # => 0.25
//}... -
Rational
# -@ -> Rational (21108.0) -
単項演算子の - です。 self の符号を反転させたものを返します。
...単項演算子の - です。
self の符号を反転させたものを返します。
//emlist[例][ruby]{
r = Rational(3, 4)
- r # => (-3/4)
//}... -
Rational
# to _ i -> Integer (21074.0) -
小数点以下を切り捨てて値を整数に変換します。
...by]{
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
//}
precision を指定した場合は指定した桁数で切り捨てた整数か
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
# <=>(other) -> -1 | 0 | 1 | nil (21049.0) -
self と other を比較して、self が大きい時に 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
/...