6件ヒット
[1-6件を表示]
(0.068秒)
別のキーワード
検索結果
先頭5件
-
Rational
# marshal _ dump -> Array (45604.0) -
Marshal.#load のためのメソッドです。 Rational::compatible#marshal_load で復元可能な配列を返します。
...Marshal.#load のためのメソッドです。
Rational::compatible#marshal_load で復元可能な配列を返します。
[注意] Rational::compatible は通常の方法では参照する事ができません。... -
Rational
# round(precision = 0) -> Integer | Rational (37204.0) -
自身ともっとも近い整数を返します。
...//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
# numerator -> Integer (36304.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
# truncate(precision = 0) -> Rational | Integer (28204.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
# magnitude -> Rational (27904.0) -
自身の絶対値を返します。
...自身の絶対値を返します。
//emlist[例][ruby]{
Rational(1, 2).abs # => (1/2)
Rational(-1, 2).abs # => (1/2)
//}... -
Rational
# quo(other) -> Rational | Float (27904.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...