るりまサーチ

最速Rubyリファレンスマニュアル検索!
341件ヒット [101-200件を表示] (0.103秒)

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

Rational#ceil(precision = 0) -> Integer | Rational (2.0)

自身と等しいかより大きな整数のうち最小のものを返します。

...//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#coerce(other) -> Array (2.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.0]
//}...

Rational#convert(*arg) -> Rational (2.0)

引数を有理数(Rational)に変換した結果を返します。

...引数を有理数(Rational)に変換した結果を返します。

@param arg 変換対象のオブジェクトです。

Kernel.#Rational の本体です。

@see Kernel.#Rational...

Rational#denominator -> Integer (2.0)

分母を返します。常に正の整数を返します。

...分母を返します。常に正の整数を返します。

@return 分母を返します。

//emlist[例][ruby]{
Rational
(7).denominator # => 1
Rational
(7, 1).denominator # => 1
Rational
(9, -4).denominator # => 4
Rational
(-2, -10).denominator # => 5
//}

@see Rational#numerator...

Rational#fdiv(other) -> Float (2.0)

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#floor(precision = 0) -> Integer | Rational (2.0)

自身と等しいかより小さな整数のうち最大のものを返します。

...[ruby]{
Rational
(3).floor # => 3
Rational
(2, 3).floor # => 0
Rational
(-3, 2).floor # => -2
//}

Rational
#to_i とは違う結果を返す事に注意してください。

//emlist[例][ruby]{
Rational
(+7, 4).to_i # => 1
Rational
(+7, 4).floor # => 1
Rational
(-7, 4).to_i # => -1
Rational
(-7, 4...
... Rational を返します。

//emlist[例][ruby]{
Rational
('-123.456').floor(+1) # => (-247/2)
Rational
('-123.456').floor(+1).to_f # => -123.5
Rational
('-123.456').floor(0) # => -124
Rational
('-123.456').floor(-1) # => -130
//}

@see Rational#ceil, Rational#round, Rational#tr...

Rational#hash -> Integer (2.0)

自身のハッシュ値を返します。

自身のハッシュ値を返します。

@return ハッシュ値を返します。


@see Object#hash

Rational#inspect -> String (2.0)

自身を人間が読みやすい形の文字列表現にして返します。

...に10進数の表記を返します。

@return 有理数の表記にした文字列を返します。

//emlist[例][ruby]{
Rational
(5, 8).inspect # => "(5/8)"
Rational
(2).inspect # => "(2/1)"
Rational
(-8, 6).inspect # => "(-4/3)"
Rational
(0.5).inspect # => "(1/2)"
//}

@see Rational#to_s...

Rational#magnitude -> Rational (2.0)

自身の絶対値を返します。

...自身の絶対値を返します。

//emlist[例][ruby]{
Rational
(1, 2).abs # => (1/2)
Rational
(-1, 2).abs # => (1/2)
//}...

Rational#marshal_dump -> Array (2.0)

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

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

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

絞り込み条件を変える

<< < 1 2 3 4 > >>