147件ヒット
[1-100件を表示]
(0.131秒)
種類
- インスタンスメソッド (136)
- 特異メソッド (11)
ライブラリ
- ビルトイン (132)
-
json
/ add / rational (11) - mathn (4)
検索結果
先頭5件
-
Rational
# hash -> Integer (9201.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
@return ハッシュ値を返します。
@see Object#hash... -
Rational
# marshal _ dump -> Array (9101.0) -
Marshal.#load のためのメソッドです。 Rational::compatible#marshal_load で復元可能な配列を返します。
...Marshal.#load のためのメソッドです。
Rational::compatible#marshal_load で復元可能な配列を返します。
[注意] Rational::compatible は通常の方法では参照する事ができません。... -
Rational
# fdiv(other) -> Float (6201.0) -
self を other で割った商を Float で返します。 other に虚数を指定することは出来ません。
...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 (3201.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 (3201.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
//}... -
Rational
# **(rhs) -> Numeric (3201.0) -
@todo
...@todo
self のべき乗を返します。 Rational になるようであれば Rational で返します。... -
Rational
# +(other) -> Rational | Float (3201.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 (3201.0) -
差を計算します。
...差を計算します。
@param other 自身から引く数
other に Float を指定した場合は、計算結果を Float で返しま
す。
//emlist[例][ruby]{
r = Rational(3, 4)
r - 1 # => (-1/4)
r - 0.5 # => 0.25
//}... -
Rational
# / (other) -> Rational | Float (3201.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) -> -1 | 0 | 1 | nil (3201.0) -
self と other を比較して、self が大きい時に 1、等しい時に 0、小さい時に -1 を返します。比較できない場合はnilを返します。
...her を比較して、self が大きい時に 1、等しい時に 0、小さい時に
-1 を返します。比較できない場合はnilを返します。
@param other 自身と比較する数値
@return -1 か 0 か 1 か nil を返します。
//emlist[例][ruby]{
Rational(2, 3) <=> Rati......onal(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
//}...