Next: , Previous: Reals and Rationals, Up: Numbers Complex Numbers

Complex numbers are the set of numbers that describe all possible points in a two-dimensional space. The two coordinates of a particular point in this space are known as the real and imaginary parts of the complex number that describes that point.

In Guile, complex numbers are written in rectangular form as the sum of their real and imaginary parts, using the symbol i to indicate the imaginary part.

     (* 3-8i 2.3+0.3i)

Polar form can also be used, with an ‘@’ between magnitude and angle,

     1@3.141592 ⇒ -1.0      (approx)
     -1@1.57079 ⇒ 0.0-1.0i  (approx)

Guile represents a complex number with a non-zero imaginary part as a pair of inexact rationals, so the real and imaginary parts of a complex number have the same properties of inexactness and limited precision as single inexact rational numbers. Guile can not represent exact complex numbers with non-zero imaginary parts.

— Scheme Procedure: complex? z
— C Function: scm_complex_p (z)

Return #t if x is a complex number, #f otherwise. Note that the sets of real, rational and integer values form subsets of the set of complex numbers, i. e. the predicate will also be fulfilled if x is a real, rational or integer number.

— C Function: int scm_is_complex (SCM val)

Equivalent to scm_is_true (scm_complex_p (val)).