るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.213秒)
トップページ > クエリ:r[x] > クエリ:self[x] > クエリ:Numeric[x] > クエリ:to_c[x]

別のキーワード

  1. numeric step
  2. _builtin numeric
  3. numeric to_c
  4. numeric conj
  5. numeric to_int

ライブラリ

クラス

検索結果

Numeric (44316.0)

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

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

演算や比較を行うメソッド(+, -, *, /, <=>)は Numeric のサブクラスで定義されま
す。Numeric で定義されているメソッドは...
...- - - -
times | - o - - - - -
to_c
| o - - - - - o
to_f | - - o...
...//emlist[例][ruby]{
if n > 0 then
n.ceil
else
n.floor
end
//}

また、任意桁の切上げ、切捨て、四捨五入を行うメソッドは以下のように
定義できます。

//emlist[][ruby]{
class Numeric
def roundup(d=0)
x = 10**d
if self > 0
self
.quo(x).ceil * x...
...o - - -
to_c
| o - - - o
to_f | - o o o o
Numeric
Integer Float Rational Complex
--------------------...

Numeric#to_c -> Complex (42147.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)
R
ational(1, 2).to_c # => ((1/2)+0i)
//}

Numeric
のサブクラスは、このメソッドを適...