るりまサーチ

最速Rubyリファレンスマニュアル検索!
352件ヒット [301-352件を表示] (0.168秒)
トップページ > クエリ:I[x] > クエリ:t[x] > クラス:Rational[x]

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. csv to_i
  5. matrix i

ライブラリ

キーワード

検索結果

<< < ... 2 3 4 >>

Rational#quo(other) -> Rational | Float (6201.0)

商を計算します。

...します。

@param other 自身を割る数

other に Float を指定した場合は、計算結果を 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 ZeroDivisionError other が 0 の時に発生します。

@see Numeric#quo...

Rational#round(precision = 0) -> Integer | Rational (6201.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 Rat...
...ional#ceil, Rational#floor, Rational#truncate...

Rational#**(rhs) -> Numeric (6101.0)

@todo

...@todo

self のべき乗を返します。 Rational になるようであれば Rational で返します。...

Rational#==(other) -> bool (6101.0)

数値として等しいか判定します。

...param other 自身と比較する数値

@return self と other が等しい場合 true を返します。
そうでなければ false を返します。

//emlist[例][ruby]{
Rational
(2, 3) == Rational(2, 3) # => true
Rational
(5) == 5 # => true
Rational
(0)...
...== 0.0 # => true
Rational
('1/3') == 0.33 # => false
Rational
('1/2') == '1/2' # => false
//}...

Rational#coerce(other) -> Array (6101.0)

自身と other が同じクラスになるよう、自身か other を変換し [other, self] という 配列にして返します。

...自身と other が同じクラスになるよう、自身か other を変換し [other, self] という
配列にして返します。

@param other 比較または変換するオブジェクト

//emlist[例][ruby]{
Rational
(1).coerce(2) # => [(2/1), (1/1)]
Rational
(1).coerce(2.2) # => [2.2, 1....

絞り込み条件を変える

Rational#marshal_dump -> Array (6001.0)

Marshal.#load のためのメソッドです。 Rational::compatible#marshal_load で復元可能な配列を返します。

...Marshal.#load のためのメソッドです。
Rational
::compatible#marshal_load で復元可能な配列を返します。

[注意] Rational::compatible は通常の方法では参照する事ができません。...
<< < ... 2 3 4 >>