84件ヒット
[1-84件を表示]
(0.053秒)
別のキーワード
種類
- インスタンスメソッド (60)
- クラス (24)
クラス
- Complex (12)
- NilClass (12)
- Numeric (12)
- String (12)
- UnboundMethod (12)
検索結果
先頭5件
-
String
# to _ c -> Complex (18217.0) -
自身を複素数 (Complex) に変換した結果を返します。
...例][ruby]{
'9'.to_c # => (9+0i)
'2.5'.to_c # => (2.5+0i)
'2.5/1'.to_c # => ((5/2)+0i)
'-3/2'.to_c # => ((-3/2)+0i)
'-i'.to_c # => (0-1i)
'45i'.to_c # => (0+45i)
'3-4i'.to_c # => (3-4i)
'-4e2-4e-2i'.to_c # => (-400.0-0.04i)
'-0.0-0.0i'.to_c #......=> (-0.0-0.0i)
'1/2+3/4i'.to_c # => ((1/2)+(3/4)*i)
'10@10'.to_c # => (-8.390715290764524-5.440211108893697i)
'-0.3_3'.to_c # => (-0.33+0i)
" \t\r\n5+3i".to_c # => (5+3i)
'5+3ix'.to_c # => (5+3i)
'ruby'.to_c # => (0+0i)
//}... -
Numeric
# to _ c -> Complex (18139.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 のサブクラスは、このメソッドを適切に再... -
Complex
# to _ c -> self (18127.0) -
self を返します。
...self を返します。
//emlist[例][ruby]{
Complex(2).to_c # => (2+0i)
Complex(-8, 6).to_c # => (-8+6i)
//}... -
NilClass
# to _ c -> Complex (18121.0) -
0+0i を返します。
...0+0i を返します。
//emlist[例][ruby]{
nil.to_c # => (0+0i)
//}... -
Numeric (92.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...覧です。実際にどのメソッドがどのクラスに定義されているかはそれぞ
れのクラスを参照してください。
=> ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]
Numeric Integer Float Rational Complex
-------......succ | - o - - -
times | - o - - -
to_c | o - - - o
to_f | - o o o 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... -
Complex (68.0)
-
複素数を扱うクラスです。
...ジェクトを作成するには、Kernel.#Complex、
Complex.rect、Complex.polar、Numeric#to_c、
String#to_c のいずれかを使用します。
//emlist[Complex オブジェクトの作り方][ruby]{
Complex(1) # => (1+0i)
Complex(2, 3) # => (2+3i)
Complex.polar(2, 3) # =>......i)
Complex('1@2') # => (-0.4161468365471424+0.9092974268256817i)
3.to_c # => (3+0i)
0.3.to_c # => (0.3+0i)
'0.3-0.5i'.to_c # => (0.3-0.5i)
'2/3+3/4i'.to_c # => ((2/3)+(3/4)*i)
'1@2'.to_c # => (-0.4161468365471424+0.9092974268256817i)
//}
Complex......オブジェクトは有理数の形式も実数の形式も扱う事ができます。
//emlist[例][ruby]{
Complex(1, 1) / 2 # => ((1/2)+(1/2)*i)
Complex(1, 1) / 2.0 # => (0.5+0.5i)
//}... -
Numeric (68.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...覧です。実際にどのメソッドがどのクラスに定義されているかはそれぞ
れのクラスを参照してください。
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Numeric Integer Fixnum Bignum Float Rational C......- - - -
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......覧です。実際にどのメソッドがどのクラスに定義されているかはそれぞ
れのクラスを参照してください。
=> ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]
Numeric Integer Float Rational Complex
-------......succ | - o - - -
times | - o - - -
to_c | o - - - o
to_f | - o o o o... -
UnboundMethod
# owner -> Class | Module (20.0) -
このメソッドが定義されている class か module を返します。
...このメソッドが定義されている class か module を返します。
//emlist[例][ruby]{
Integer.instance_method(:to_s).owner # => Integer
Integer.instance_method(:to_c).owner # => Numeric
Integer.instance_method(:hash).owner # => Kernel
//}...