Complex literals

Support for complex numbers is provided by Math::MPC, which is a Perl interface to the MPC library.

3 + 4i          # complex: 3+4i
3:4             # =//=
Complex(3, 4)   # =//=

Complex numbers are deeply integrated into the language and can be used in combination with all the other Number types (with implicit propagation):

sqrt(-1)        # i
log(-1)         # 3.14159265358979323846264338327950288419716939938i
4 + sqrt(-1)    # 4+i
(3+4i)**2       # -7+24i

All complex numbers are Number object:

(3 + 4i).class       # Number
Complex(3, 4).class  # =//=

See the Number documentation for more information.