The Complex routine

Combined from primary sources listed below.

In class ComplexStr ( Type/ComplexStr )§

See primary docmentation in context for method Complex.

method Complex§

method Complex

Returns the Complex value of the ComplexStr.

In class Cool ( Type/Cool )§

See primary docmentation in context for method Complex.

method Complex§

multi method Complex()

Coerces the invocant to a Numeric and calls its .Complex method. Fails if the coercion to a Numeric cannot be done.

say 1+1i.Complex;         # OUTPUT: «1+1i␤»
say π.Complex;            # OUTPUT: «3.141592653589793+0i␤»
say <1.3>.Complex;        # OUTPUT: «1.3+0i␤»
say (-4/3).Complex;       # OUTPUT: «-1.3333333333333333+0i␤»
say "foo".Complex.^name;  # OUTPUT: «Failure␤»

In role Real ( Type/Real )§

See primary docmentation in context for method Complex.

method Complex§

method Complex(Real:D: --> Complex:D)

Converts the number to a Complex with the number converted to a Num as its real part and 0e0 as the imaginary part.