Arithmetic/Complex: Difference between revisions
→{{header|Ruby}}: Removed pre 1.9 info
(→{{header|Ruby}}: CMath is removed from Standard Library since Ruby 2.5) |
(→{{header|Ruby}}: Removed pre 1.9 info) |
||
Line 4,164:
=={{header|Ruby}}==
<lang ruby>
▲# Three ways to write complex numbers:
a = Complex(1, 1) # 1. call Kernel#Complex
i = Complex::I # 2. use Complex::I
b = 3.14159 + 1.25 * i
c = '1/2+3/4i'.to_c # 3. Use the .to_c method from String, result ((1/2)+(3/4)*i)
c = 1.0/2+3/4i # (0.5-(3/4)*i)
Line 4,184 ⟶ 4,181:
''Notes:''
* All of these operations are safe with other numeric types. For example, <code>42.conjugate</code> returns 42.
|