るりまサーチ

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

別のキーワード

  1. numeric step
  2. _builtin numeric
  3. numeric numerator
  4. numeric coerce
  5. numeric ceil

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 5 ... > >>

Numeric#quo(other) -> Rational | Float | Complex (30169.0)

self を other で割った商を返します。 整商を得たい場合は Numeric#div を使ってください。

...self を other で割った商を返します。
整商を得たい場合は Numeric#div を使ってください。

Numeric
#fdiv が結果を Float で返すメソッドなのに対して quo はなるべく正確な数値を返すことを意図しています。
具体的には有理数の範...
...囲に収まる計算では Rational の値を返します。
Float や Complex が関わるときはそれらのクラスになります。

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


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

//emlist[例][ruby]{
1.quo(3) #=> (1/3)
1.0.quo(3) #=> 0.3333333333333333
1.quo(3.0) #=> 0.3333333333333333
1.quo(0.5) #=> 2.0

Complex(1, 1).quo(1) #=> ((1/1)+(1/1)*i)
1.quo(Complex(1, 1)) #=> ((1/2)-(1/2)*i)
//}

@see Numeric#fdiv...

Numeric#round -> Integer (30155.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#truncat...

Numeric#ceil -> Integer (30149.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#floor -> Integer (30149.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#floor(ndigits = 0) -> Integer (30149.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#floor(ndigits = 0) -> Integer | Float (30149.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#truncate -> Integer (30149.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#imag -> 0 (30137.0)

常に 0 を返します。

...常に 0 を返します。

//emlist[例][ruby]{
12.imag # => 0
-
12.imag # => 0
1.2.imag # => 0
-
1.2.imag # => 0
//}

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

@see Numeric#real、Complex#imag...

Numeric#imaginary -> 0 (30137.0)

常に 0 を返します。

...常に 0 を返します。

//emlist[例][ruby]{
12.imag # => 0
-
12.imag # => 0
1.2.imag # => 0
-
1.2.imag # => 0
//}

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

@see Numeric#real、Complex#imag...

Numeric#<=>(other) -> -1 | 0 | 1 | nil (30136.0)

自身が other より大きい場合に 1 を、等しい場合に 0 を、小さい場合には -1 をそれぞれ返します。 自身と other が比較できない場合には nil を返します。

...が other より大きい場合に 1 を、等しい場合に 0 を、小さい場合には -1 をそれぞれ返します。
自身と other が比較できない場合には nil を返します。

Numeric
のサブクラスは、上の動作を満たすよう このメソッドを適切に再定...
...義しなければなりません。

@param other 自身と比較したい数値を指定します。

//emlist[例][ruby]{
1 <=> 0 #=> 1
1 <=> 1 #=> 0
1 <=> 2 #=> -1
1 <=> "0" #=> nil
//}...

絞り込み条件を変える

Numeric#fdiv(other) -> Float | Complex (30131.0)

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...
<< < 1 2 3 4 5 ... > >>