るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. _builtin float
  2. float to_d
  3. json float
  4. float rationalize
  5. fiddle type_float

キーワード

検索結果

Rational#-(other) -> Rational | Float (54688.0)

差を計算します。

...差を計算します。

@param other 自身から引く数

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

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

Rational#to_f -> Float (736.0)

自身の値を最も良く表現する Float に変換します。

...{
Rational
(2).to_f # => 2.0
Rational
(9, 4).to_f # => 2.25
Rational
(-3, 4).to_f # => -0.75
Rational
(20, 3).to_f # => 6.666666666666667
Rational
(1, 10**1000).to_f # => 0.0
Rational
(-1, 10**1000).to_f # => -0.0
Rational
(10**1000).to_f # => Infinity
Rational
(...

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

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

...す。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#fdiv(other) -> Float (664.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#/(other) -> Rational | Float (655.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#quo(other) -> Rational | Float (655.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 (652.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 (652.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
//}...