better formatting of root values

This commit is contained in:
Krishna Vedala 2020-04-23 19:26:31 -04:00
parent 9dbdd50c78
commit aab7a206cf
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -27,13 +27,13 @@ long double complex function(double *coeffs, unsigned int degree, long double co
return out; return out;
} }
const char *complex_str(long double complex x) static inline char *complex_str(long double complex x)
{ {
static char msg[50]; static char msg[50];
double r = creal(x); double r = creal(x);
double c = cimag(x); double c = cimag(x);
sprintf(msg, "%.04g%c%.04gi", r, c >= 0 ? '+' : '-', c >= 0 ? c : -c); sprintf(msg, "% 7.04g%+7.04gj", r, c);
return msg; return msg;
} }