るりまサーチ

最速Rubyリファレンスマニュアル検索!
333件ヒット [201-300件を表示] (0.191秒)
トップページ > クエリ:t[x] > クエリ:r[x] > 種類:インスタンスメソッド[x] > クエリ:ruby[x] > クラス:Rational[x]

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

Rational#/(other) -> Rational | Float (6244.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#quo(other) -> Rational | Float (6244.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#*(other) -> Rational | Float (6238.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...

Rational#**(other) -> Rational | Float (6238.0)

冪(べき)乗を計算します。

...

@param other 自身を other 乗する数

other に Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、計算結果が無理数だった場合は Float
を返します。

//emlist[例][ruby]{
r
= Rational(3, 4)
r
** Rational(2, 1) #...
...=> (9/16)
r
** 2 # => (9/16)
r
** 2.0 # => 0.5625
r
** Rational(1, 2) # => 0.866025403784439
//}...
...(べき)乗を計算します。

@param other 自身を other 乗する数
@raise ArgumentError 計算結果の分母・分子が巨大すぎる場合に発生します。

other に Float を指定した場合は、計算結果を Float で返しま
す。other が有理数であっても、計算...
...結果が無理数だった場合は Float
を返します。

//emlist[例][ruby]{
r
= Rational(3, 4)
r
** Rational(2, 1) # => (9/16)
r
** 2 # => (9/16)
r
** 2.0 # => 0.5625
r
** Rational(1, 2) # => 0.866025403784439
//}...

Rational#+(other) -> Rational | Float (6232.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#-(other) -> Rational | Float (6226.0)

差を計算します。

...差を計算します。

@param other 自身から引く数

other に Float を指定した場合は、計算結果を Float で返しま
す。

//emlist[例][ruby]{
r
= Rational(3, 4)
r
- 1 # => (-1/4)
r
- 0.5 # => 0.25
//}...

Rational#-@ -> Rational (6220.0)

単項演算子の - です。 self の符号を反転させたものを返します。

...単項演算子の - です。
self の符号を反転させたものを返します。

//emlist[例][ruby]{
r
= Rational(3, 4)
- r # => (-3/4)
//}...

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

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

...ものを返します。

@param precision 計算結果の精度

@raise TypeError precision に整数以外のものを指定すると発生します。

//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#<=>(other) -> -1 | 0 | 1 | nil (6208.0)

self と other を比較して、self が大きい時に 1、等しい時に 0、小さい時に -1 を返します。比較できない場合はnilを返します。

...ther を比較して、self が大きい時に 1、等しい時に 0、小さい時に
-1 を返します。比較できない場合はnilを返します。

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

@return -1 か 0 か 1 か nil を返します。

//emlist[例][ruby]{
Rational
(2, 3) <=> Rat...
...ional(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
//}...
<< < 1 2 3 4 > >>