summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolfe Power <[email protected]>2020-04-15 05:05:37 -0400
committerraveit65 <[email protected]>2020-04-25 16:44:40 +0200
commit8a56a6107dec16b7876721283de2f56e7a9e3169 (patch)
tree0c6c76561ee5242a2e7cdb7abe20983434badc80
parent72e7621606a8bce6be18998d8eca36d463299be1 (diff)
downloadmate-calc-8a56a6107dec16b7876721283de2f56e7a9e3169.tar.bz2
mate-calc-8a56a6107dec16b7876721283de2f56e7a9e3169.tar.xz
Fix empty string return for canceling complex expressions
-rw-r--r--src/mp-serializer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mp-serializer.c b/src/mp-serializer.c
index 4debd83..3967cbc 100644
--- a/src/mp-serializer.c
+++ b/src/mp-serializer.c
@@ -209,7 +209,10 @@ mp_to_string(MpSerializer *serializer, const MPNumber *x, int *n_digits)
if (n_complex_digits > *n_digits)
*n_digits = n_complex_digits;
if (strcmp(s->str, "0") == 0 || strcmp(s->str, "+0") == 0 || strcmp(s->str, "−0") == 0) {
- /* Ignore */
+ /* Ignore unless the real part was also zero and string was cleared*/
+ if (string->len == 0) {
+ g_string_append(string, "0");
+ }
}
else if (strcmp(s->str, "1") == 0) {
g_string_append(string, "i");