Arithmetic/Complex: Difference between revisions
Content deleted Content added
Line 2,793:
=={{header|Oforth}}==
<lang Oforth>
Complex method: re
Complex method: im
Complex method: initialize
Complex method: <<
Integer method: asComplex
Float method: asComplex
Complex new(0, 1) Constant new: I
Complex method: ==(c)
Complex method: norm
Complex method: conj
Complex method: +(c)
Complex method: -(c)
Complex method: *(c)
Complex method: inv
| n |
@re sq @im sq + asFloat ->n
Complex new(@re n /, @im neg n / ) ;
Complex method: /(c)
Usage :
<lang Oforth>2 3.2 I * +
Complex new(2, 3) 1.2 +
Complex new(2, 3) 1.2 *
2 Complex new(2, 3) /
{{out}}
|