Complex number syntax
Factor handbook » The language » Syntax » Literals » Number syntax

Prev:Float syntax


A complex number is given by two components, a "real" part and an "imaginary" part. The components must either be integers, ratios or floats.
C{ 1/2 1/3 } ! the complex number 1/2+1/3i C{ 0 1 } ! the imaginary unit

A single token ending in j can also express a complex number:
-1.5+3.0j ! equivalent to C{ -1.5 3.0 } 1/2-1/3j ! equivalent to C{ 1/2 -1/3 } 2j ! equivalent to C{ 0 2 } 1e-3+2e+4j ! exponents may contain signs

The bare token j remains a word name, not a number.
C{


More information on complex numbers can be found in Complex numbers.