るりまサーチ

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

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. ipaddr to_i
  5. kernel $-i

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Numeric (44304.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...値を表す抽象クラスです。Integer や Float などの数値クラス
Numeric のサブクラスとして実装されています。

演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッド...
...提供されているメソッド
(+, -, *, /, %) を利用して定義されるものがほとんどです。
つまり Numeric で定義されているメソッドは、Numeric のサブクラスとして新たに数値クラスを定義した時に、
演算メソッド(+, -, *, /, %, <=>, coerce...
...を表しメソッド定義などではこの記法を利用します。

効率のため Numeric のメソッドと同じメソッドがサブクラスで再定義されている場合があります。

Numeric
#coerce メソッドを使うことによって異なる数値クラス間で演算を...

Numeric#integer? -> bool (33243.0)

自身が Integer かそのサブクラスのインスタンスの場合にtrue を返し ます。そうでない場合に false を返します。

... Integer かそのサブクラスのインスタンスの場合にtrue を返し
ます。そうでない場合に false を返します。

Numeric
のサブクラスは、このメソッドを適切に再定義しなければなりません。

//emlist[例][ruby]{
(1.0).integer? #=> false
(1).int...
...eger? #=> true
//}

@see Numeric#real?...

Integer#remainder(other) -> Numeric (30221.0)

self を other で割った余り r を返します。

...//emlist[][ruby]{
5.remainder(3) # => 2
-5.remainder(3) # => -2
5.remainder(-3) # => 2
-5.remainder(-3) # => -2

-1234567890987654321.remainder(13731) # => -6966
-1234567890987654321.remainder(13731.24) # => -9906.22531493148
//}

@see Integer#divmod, Integer#modulo, Numeric#modul...

Numeric#to_int -> Integer (27325.0)

self.to_i と同じです。

...self.to_i と同じです。

//emlist[例][ruby]{
(2+0i).to_int # => 2
Rational(3).to_int # => 3
//}...

Numeric#denominator -> Integer (27315.0)

自身を Rational に変換した時の分母を返します。

...自身を Rational に変換した時の分母を返します。

@return 分母を返します。


@see Numeric#numerator、Integer#denominator、Float#denominator、Rational#denominator、Complex#denominator...

絞り込み条件を変える

Integer#divmod(other) -> [Integer, Numeric] (27310.0)

self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。

...self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にし
て返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。

@param other self を割る数。

@see Numeric#divmod...

Integer#fdiv(other) -> Numeric (27221.0)

self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。

...指定します。

例:

654321.fdiv(13731) # => 47.652829364212366
654321.fdiv(13731.24) # => 47.65199646936475

-1234567890987654321.fdiv(13731) # => -89910996357705.52
-1234567890987654321.fdiv(13731.24) # => -89909424858035.72
@see Numeric#quo, Numeric#div, Integer#div...

Numeric#ceil -> Integer (27221.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...

Integer#ceil(ndigits = 0) -> Integer | Float (27215.0)

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

...@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
正の整数を指定した場合、Float を返します。
小数点以下を、最大 n 桁にします。
負の整数を指定した場合、Integer を返し...
...ます。
小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1.0
18.ceil(-1) # => 20
(-18).ceil(-1) # => -10
//}

@see Numeric#ceil...

Integer#ceil(ndigits = 0) -> Integer (27209.0)

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

...@param ndigits 10進数での小数点以下の有効桁数を整数で指定します。
負の整数を指定した場合、小数点位置から左に少なくとも n 個の 0 が並びます。

//emlist[][ruby]{
1.ceil # => 1
1.ceil(2) # => 1
18.ceil(-1)...
...# => 20
(-18).ceil(-1) # => -10
//}

@see Numeric#ceil...

絞り込み条件を変える

Numeric#div(other) -> Integer (27209.0)

self を other で割った整数の商 q を返します。

...りは Numeric#modulo で求められます。
div はメソッド / を呼びだし、floorを取ることで計算されます。

メソッド / の定義はサブクラスごとの定義を用います。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
p 3.div(2) # =>...
...1
p (-3).div(2) # => -2
p (-3.0).div(2) # => -2
//}...
<< 1 2 3 ... > >>