Credits Overview Plotting Styles Commands Terminals

Complex format specifiers

gprintf offers two format specifiers, %C and %Ci, to print a complex value. Both apply format %g separately to the real and imaginary components using any optional field modifiers that were given. [EXPERIMENTAL]

Suppose complex Z = {1.2, -3.4}.

     gprintf("%C", Z) produces the string "{1.2, -3.4}"
     gprintf("%Ci", Z) produces the string "1.2 - 3.4i"

The output of "%Ci" can be further customized by the command set imaginary_i to replace the character "i" that follows the imaginary component with a different character or character sequence. See imaginary_i.

Examples:

     Z = {1.2222, 0.3333}
     gprintf("%.2C", Z)            # {1.2, 0.33}
     gprintf("%.3Ci", Z)           # 1.22 + 0.333i
     set imaginary_i "{/Times*0.5 im}"
     gprintf("[%Ci]", Z)           # [1.2222 + 0.3333im]
     gprintf("[%.1Ci]", -Z)        # [-1 - 0.3im]