py: Fix cmath.log10; fix printing of complex number with negative imag.

This commit is contained in:
Damien George
2015-02-02 12:52:14 +00:00
parent 471b2a8906
commit f49782f005
2 changed files with 9 additions and 3 deletions

View File

@@ -58,7 +58,10 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *
print(env, "%sj", buf);
} else {
mp_format_float(o->real, buf, sizeof(buf), 'g', 7, '\0');
print(env, "(%s+", buf);
print(env, "(%s", buf);
if (o->imag >= 0) {
print(env, "+");
}
mp_format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0');
print(env, "%sj)", buf);
}
@@ -69,7 +72,10 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *
print(env, "%sj", buf);
} else {
sprintf(buf, "%.16g", (double)o->real);
print(env, "(%s+", buf);
print(env, "(%s", buf);
if (o->imag >= 0) {
print(env, "+");
}
sprintf(buf, "%.16g", (double)o->imag);
print(env, "%sj)", buf);
}