[genius] Mon May 04 17:34:29 2015 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Mon May 04 17:34:29 2015 Jiri (George) Lebl <jirka 5z com>
- Date: Mon, 4 May 2015 22:43:05 +0000 (UTC)
commit a34cc21c72a4092ab7cc356a0e01ba3cf519200c
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Mon May 4 17:36:39 2015 -0500
Mon May 04 17:34:29 2015 Jiri (George) Lebl <jirka 5z com>
* src/mpwrap.c: Fix output of chopped imaginary numbers, chopped
negative numbers are now displayed as -0.0
* src/geniustests.txt: add some tests for the above
ChangeLog | 7 +++++++
NEWS | 2 ++
src/calc.h | 4 ++--
src/geniustests.txt | 8 ++++++++
src/mpwrap.c | 11 +++++++----
5 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fb8878b..05380a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon May 04 17:34:29 2015 Jiri (George) Lebl <jirka 5z com>
+
+ * src/mpwrap.c: Fix output of chopped imaginary numbers, chopped
+ negative numbers are now displayed as -0.0
+
+ * src/geniustests.txt: add some tests for the above
+
Sun Apr 26 11:57:32 2015 Jiri (George) Lebl <jirka 5z com>
* examples/Makefile.am, examples/explicit-fdm-heat.gel: Add example
diff --git a/NEWS b/NEWS
index bf127ee..5c1a2cd 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Changes to 1.0.21
* Add vibrating drumhead modes example, heat equation with explicit FDM,
improve the Laplace FDM example
+* Fix output of chopped floating point numbers, especially chopped
+ imaginary parts
* During making of these changes the author (Jiri) was partially supported by
NSF grant DMS 1362337 and the Oklahoma State University
diff --git a/src/calc.h b/src/calc.h
index 89a88d5..0e54fc5 100644
--- a/src/calc.h
+++ b/src/calc.h
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2014 Jiri (George) Lebl
+ * Copyright (C) 1997-2015 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -29,7 +29,7 @@
#include "structs.h"
-#define GENIUS_COPYRIGHT_STRING N_("Copyright (C) 1997-2014 Jiří (George) Lebl")
+#define GENIUS_COPYRIGHT_STRING N_("Copyright (C) 1997-2015 Jiří (George) Lebl")
typedef enum {
GEL_NO_ERROR = 0,
diff --git a/src/geniustests.txt b/src/geniustests.txt
index 66f87eb..83e8579 100644
--- a/src/geniustests.txt
+++ b/src/geniustests.txt
@@ -1212,6 +1212,14 @@ Im(4i) 4
Re(4i) 0
Re(4) 4
Im(4) 0
+1.1+0.0001i 1.1+0.0001i
+1.1-0.0001i 1.1-0.0001i
+1-0.0001i 1-0.0001i
+1.1+0.000000000000000000000000000000000000000000000001i 1.1+0.0i
+1.1-0.000000000000000000000000000000000000000000000001i 1.1-0.0i
+1+0.000000000000000000000000000000000000000000000001i 1+0.0i
+0.00000000000000000000000000000000000001+1.1i 0.0+1.1i
+-0.00000000000000000000000000000000000001+1.1i -0.0+1.1i
load "nullspacetest.gel" true
load "longtest.gel" true
load "testprec.gel" true
diff --git a/src/mpwrap.c b/src/mpwrap.c
index 213eaed..d407232 100644
--- a/src/mpwrap.c
+++ b/src/mpwrap.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2012 Jiri (George) Lebl
+ * Copyright (C) 1997-2015 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -3111,10 +3111,13 @@ str_getstring_f (mpfr_ptr num,
/* approximately the exponent base 10 */
e = mpfr_get_exp (num) / 3.32192809489;
if (e < -chop) {
+ char *sign = "";
+ if (mpfr_sgn (num) < 0)
+ sign = "-";
if (scientific_notation)
- return g_strconcat ("0e0", postfix, NULL);
+ return g_strconcat (sign, "0e0", postfix, NULL);
else
- return g_strdup ("0.0");
+ return g_strconcat (sign, "0.0", postfix, NULL);
}
}
@@ -5310,7 +5313,7 @@ mpw_getstring_chop (mpw_ptr num, int max_digits,
if (justimaginary) {
r = p2;
p2 = NULL;
- } else if (mpwl_sgn(num->i)>=0) {
+ } else if (p2[0] != '+' && p2[0] != '-') {
if (add_parenths)
r = g_strconcat("(",p1,"+",p2,")",NULL);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]