1109件ヒット
[1-100件を表示]
(0.041秒)
クラス
- Bignum (3)
- CSV (12)
- Fixnum (3)
- Float (36)
- Integer (288)
- Numeric (249)
-
OpenSSL
:: BN (12) - OptionParser (144)
- Range (12)
- Socket (48)
- Time (53)
- UnboundMethod (12)
モジュール
- GC (24)
- Kernel (24)
- Math (4)
-
OpenSSL
:: ASN1 (12) -
Socket
:: Constants (48)
キーワード
- % (12)
- * (12)
- ** (12)
- + (12)
- - (12)
- -@ (12)
-
/ (24) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
AI
_ NUMERICHOST (24) -
AI
_ NUMERICSERV (24) - Converters (12)
-
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (5) -
NI
_ NUMERICHOST (24) -
NI
_ NUMERICSERV (24) - NUMERICSTRING (12)
- Ruby用語集 (12)
- [] (24)
- at (53)
- bigdecimal (12)
- ceil (24)
-
check
_ signedness (24) - coerce (24)
- denominator (12)
- div (12)
- divmod (18)
- downto (24)
- fdiv (12)
- floor (36)
- integer? (12)
- matrix (12)
- modulo (12)
- numerator (12)
- on (144)
- owner (12)
- pow (24)
- real? (12)
- remainder (12)
- round (24)
- rsqrt (4)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) - size (12)
- stat (24)
- step (93)
- times (24)
-
to
_ i (12) -
to
_ int (12) - truncate (36)
- upto (24)
検索結果
先頭5件
-
Numeric
# integer? -> bool (39141.0) -
自身が Integer かそのサブクラスのインスタンスの場合にtrue を返し ます。そうでない場合に false を返します。
...自身が Integer かそのサブクラスのインスタンスの場合にtrue を返し
ます。そうでない場合に false を返します。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
//emlist[例][ruby]{
(1.0).integer? #=> fal......se
(1).integer? #=> true
//}
@see Numeric#real?... -
Numeric (38290.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...値を表す抽象クラスです。Integer や Float などの数値クラス
は Numeric のサブクラスとして実装されています。
演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッド......提供されているメソッド
(+, -, *, /, %) を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce......を表しメソッド定義などではこの記法を利用します。
効率のため Numeric のメソッドと同じメソッドがサブクラスで再定義されている場合があります。
Numeric#coerce メソッドを使うことによって異なる数値クラス間で演算を... -
Numeric
# floor(ndigits = 0) -> Integer | Float (21131.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...、Integer を返します。
小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[例][ruby]{
1.floor #=> 1
1.2.floor #=> 1
(-1.2).floor #=> -2
(-1.5).floor #=> -2
//}
@see Numeric#ceil, Numeric#round, Numeric#truncate
@see Integer#floor... -
Numeric
# floor(ndigits = 0) -> Integer (21125.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。
//emlist[例][ruby]{
1.floor #=> 1
1.2.floor #=> 1
(-1.2).floor #=> -2
(-1.5).floor #=> -2
//}
@see Numeric#ceil, Numeric#round, Numeric#truncate
@see Integer#floor... -
Numeric
# ceil -> Integer (21119.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
# coerce(other) -> [Numeric] (21119.0) -
自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。
...列にして返します。
デフォルトでは self と other を Float に変換して [other, self] という配列にして返します。
Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。
以下は Rational の coerce のソースです......//emlist[例][ruby]{
# lib/rational.rb より
def 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
//}
数値クラスの算術演算子は通常自分と演算できないク......んでいます。
//emlist[例][ruby]{
# lib/rational.rb より
def + (a)
if a.kind_of?(Rational)
# 長いので省略
elsif a.kind_of?(Integer)
# 長いので省略
elsif a.kind_of?(Float)
Float(self) + a
else
x, y = a.coerce(self)
x + y
end
end
//}
@param other... -
Numeric
# floor -> Integer (21119.0) -
自身と等しいかより小さな整数のうち最大のものを返します。
...自身と等しいかより小さな整数のうち最大のものを返します。
//emlist[例][ruby]{
1.floor #=> 1
1.2.floor #=> 1
(-1.2).floor #=> -2
(-1.5).floor #=> -2
//}
@see Numeric#ceil, Numeric#round, Numeric#truncate... -
Numeric
# round -> Integer (21119.0) -
自身ともっとも近い整数を返します。
...0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。いわゆる四捨五入ですが、偶数丸めではありません。
//emlist[例][ruby]{
1.round #=> 1
1.2.round #=> 1
(-1.2).round #=> -1
(-1.5).round #=> -2
//}
@see Numeric#ceil, Numeric#floor, Numeric#truncate... -
Numeric
# truncate -> Integer (21119.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
# / (other) -> Numeric (21113.0) -
除算の演算子です。 self を other で割った商を返します。
...除算の演算子です。
self を other で割った商を返します。
Numeric では定義されておらず、サブクラスの実装によります。
@see Integer#/, Float#/, Rational#/, Complex#/... -
Numeric
# denominator -> Integer (21113.0) -
自身を Rational に変換した時の分母を返します。
...自身を Rational に変換した時の分母を返します。
@return 分母を返します。
@see Numeric#numerator、Integer#denominator、Float#denominator、Rational#denominator、Complex#denominator...