611件ヒット
[1-100件を表示]
(0.072秒)
ライブラリ
- ビルトイン (611)
キーワード
- % (12)
- +@ (12)
- -@ (12)
-
/ (12) - <=> (12)
- abs (12)
- abs2 (12)
- angle (12)
- arg (12)
- ceil (12)
- coerce (12)
- conj (12)
- conjugate (12)
- denominator (12)
- div (12)
- divmod (12)
- eql? (12)
- fdiv (12)
- finite? (9)
- floor (12)
- i (12)
- imag (12)
- imaginary (12)
- infinite? (9)
- integer? (12)
- magnitude (12)
- modulo (12)
- negative? (10)
- nonzero? (12)
- numerator (12)
- phase (12)
- polar (12)
- positive? (10)
- quo (12)
- real (12)
- real? (12)
- rect (12)
- rectangular (12)
- remainder (12)
- round (12)
- step (93)
-
to
_ c (12) -
to
_ int (12) - truncate (12)
- zero? (12)
検索結果
先頭5件
-
Numeric
# to _ c -> Complex (6142.0) -
自身を複素数 (Complex) に変換します。Complex(self, 0) を返します。
...自身を複素数 (Complex) に変換します。Complex(self, 0) を返します。
//emlist[例][ruby]{
1.to_c # => (1+0i)
-1.to_c # => (-1+0i)
1.0.to_c # => (1.0+0i)
Rational(1, 2).to_c # => ((1/2)+0i)
//}
Numeric のサブクラスは、このメソッド... -
Numeric
# coerce(other) -> [Numeric] (6119.0) -
自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。
...her を Float に変換して [other, self] という配列にして返します。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
以下は Rational の coerce のソースです。other が自身の知らない数値クラスであった場......f coerce(other)
if other.kind_of?(Float)
return other, self.to_f
elsif other.kind_of?(Integer)
return Rational.new!(other, 1), self
else
super
end
end
//}
数値クラスの算術演算子は通常自分と演算できないクラスをオペランドとして受け
取ると co......erce を使って自分とオペランドを変換した上で演算を行います。
以下は Rational の + メソッドを一部省略したものです。
引数が自身の知らない数値クラスである場合、引数の coerce により自身を変換してから
+ 演算子を呼ん... -
Numeric
# conj -> Numeric (6107.0) -
常に self を返します。
... Complex かそのサブクラスのインスタンスの場合は、自身の共役複素数(実数の場合は常に自身)を返します。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
//emlist[例][ruby]{
10.conj # => 10
0.1.c......onj # => 0.1
(2/3r).conj # => (2/3)
//}
@see Complex#conj... -
Numeric
# conjugate -> Numeric (6107.0) -
常に self を返します。
... Complex かそのサブクラスのインスタンスの場合は、自身の共役複素数(実数の場合は常に自身)を返します。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
//emlist[例][ruby]{
10.conj # => 10
0.1.c......onj # => 0.1
(2/3r).conj # => (2/3)
//}
@see Complex#conj... -
Numeric
# ceil -> Integer (6101.0) -
自身と等しいかより大きな整数のうち最小のものを返します。
...自身と等しいかより大きな整数のうち最小のものを返します。
//emlist[例][ruby]{
1.ceil #=> 1
1.2.ceil #=> 2
(-1.2).ceil #=> -1
(-1.5).ceil #=> -1
//}
@see Numeric#floor, Numeric#round, Numeric#truncate... -
Numeric
# rect -> [Numeric , Numeric] (6101.0) -
[self, 0] を返します。
...[self, 0] を返します。
//emlist[例][ruby]{
1.rect # => [1, 0]
-1.rect # => [-1, 0]
1.0.rect # => [1.0, 0]
-1.0.rect # => [-1.0, 0]
//}
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
@see Complex#rect... -
Numeric
# rectangular -> [Numeric , Numeric] (6101.0) -
[self, 0] を返します。
...[self, 0] を返します。
//emlist[例][ruby]{
1.rect # => [1, 0]
-1.rect # => [-1, 0]
1.0.rect # => [1.0, 0]
-1.0.rect # => [-1.0, 0]
//}
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
@see Complex#rect... -
Numeric
# truncate -> Integer (6101.0) -
0 から 自身までの整数で、自身にもっとも近い整数を返します。
...0 から 自身までの整数で、自身にもっとも近い整数を返します。
//emlist[例][ruby]{
1.truncate #=> 1
1.2.truncate #=> 1
(-1.2).truncate #=> -1
(-1.5).truncate #=> -1
//}
@see Numeric#ceil, Numeric#floor, Numeric#round... -
Numeric
# fdiv(other) -> Float | Complex (3133.0) -
self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。
...self を other で割った商を Float で返します。
ただし Complex が関わる場合は例外です。
その場合も成分は Float になります。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
@param other 自身を割る......数を指定します。
//emlist[例][ruby]{
1.fdiv(3) #=> 0.3333333333333333
Complex(1, 1).fdiv 1 #=> (1.0+1.0i)
1.fdiv Complex(1, 1) #=> (0.5-0.5i)
//}
@see Numeric#quo...