ComplexToString

Converts a numeric value of a complex type to a text string.

string ComplexToString(
   complex value,     // complex number
   int     digits=8   // number of decimal places
   );

Parameters

value

[in]  Complex number.

digits

[in]  Precision format. If the value of digits is in the range from 0 to 16, the string representation of the real and imaginary parts of the complex number will be obtained with the specified number of decimal places. If the value of digits is in the range from -1 to -16, the string representation of the complex number will be obtained in scientific format with the specified number of decimal places. In all other cases, the string representation of the number will contain 8 decimal places.

Return Value

A string containing the character representation of the complex number in the specified precision format.

Example:

   vectorc vecc=vectorc::Random(10,-1.0-1i,1+1i);
   string  str_complex=ComplexToString(vecc[0]);
   Print(str_complex);
   complex value=StringToComplex(str_complex);
   Print(value);
 
  /*
   (0.55906387,-0.18868503)
   (0.55906387,-0.18868503)
  */

See also

Complex number (complex, complexf), DoubleToString, StringToComplex